[jboss-cvs] JBossAS SVN: r81081 - in trunk/varia: src/etc and 15 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 12:04:40 EST 2008
Author: dimitris at jboss.org
Date: 2008-11-14 12:04:40 -0500 (Fri, 14 Nov 2008)
New Revision: 81081
Modified:
trunk/varia/build-test.xml
trunk/varia/build.xml
trunk/varia/pom.xml
trunk/varia/src/etc/license-info.xml
trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfigurator.java
trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfiguratorMBean.java
trunk/varia/src/main/org/jboss/mail/SessionObjectFactory.java
trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java
trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java
trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java
trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java
trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java
trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java
trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java
trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java
trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java
trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java
trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java
trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java
trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java
trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java
trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java
trunk/varia/src/main/org/jboss/services/binding/impl/Util.java
trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java
trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java
trunk/varia/src/main/org/jboss/varia/deployment/BeanShellScriptClient.java
trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellDeployer.java
trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptClient.java
trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptDeployer.java
trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK5.java
trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK6.java
trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java
trunk/varia/src/resources/beanshell/bsh-deployers-jboss-beans.xml
trunk/varia/src/resources/jmx/html/filterView.jsp
trunk/varia/src/resources/jmx/html/genericError.jsp
trunk/varia/src/resources/jmx/html/images/logo.gif
trunk/varia/src/resources/services/deployment/templates/jms-queue/template-config.xml
trunk/varia/src/resources/services/deployment/templates/jms-topic/template-config.xml
trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/alt_input.xml
trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/input.xml
trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt.xml
trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt_input.xml
trunk/varia/src/resources/varia/threaddump/index.jsp
trunk/varia/src/resources/varia/threaddump/web.xml
trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
Log:
fix svn properties
Property changes on: trunk/varia/build-test.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/build.xml
===================================================================
--- trunk/varia/build.xml 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/build.xml 2008-11-14 17:04:40 UTC (rev 81081)
@@ -670,8 +670,8 @@
description="Validate the source tree headers">
<java classname="org.jboss.tools.license.ValidateLicenseHeaders"
fork="true">
- <!--<arg value="-addheader" />-->
- <arg value="${project.root}" />
+ <arg value="-addheader"/>
+ <arg value="${project.root}"/>
<classpath>
<pathelement location="${build.classes}" />
</classpath>
Property changes on: trunk/varia/pom.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/etc/license-info.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfigurator.java
===================================================================
--- trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfigurator.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfigurator.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,61 +1,61 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jmx.examples.configuration;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-/**
- * A SampleMBeanConfigurator.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class SampleMBeanConfigurator extends MBeanConfiguratorSupport implements SampleMBeanConfiguratorMBean
-{
- private ObjectName sampleServiceObjectName;
-
- public ObjectName getSampleServiceObjectName()
- {
- return sampleServiceObjectName;
- }
-
- public void setSampleServiceObjectName(ObjectName sampleServiceObjectName)
- {
- this.sampleServiceObjectName = sampleServiceObjectName;
- }
-
-
- @Override
- public void mbeanRegistered(ObjectName objectName) throws Exception
- {
- if (objectName.equals(sampleServiceObjectName))
- {
- String value = getServiceBindingManager().getStringBinding(objectName.getCanonicalName(), null, "socket://${host}:${port}", "localhost", 9999);
- MBeanServer server = getServer();
- server.setAttribute(objectName, new Attribute("TestAttribute", value));
- }
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jmx.examples.configuration;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * A SampleMBeanConfigurator.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SampleMBeanConfigurator extends MBeanConfiguratorSupport implements SampleMBeanConfiguratorMBean
+{
+ private ObjectName sampleServiceObjectName;
+
+ public ObjectName getSampleServiceObjectName()
+ {
+ return sampleServiceObjectName;
+ }
+
+ public void setSampleServiceObjectName(ObjectName sampleServiceObjectName)
+ {
+ this.sampleServiceObjectName = sampleServiceObjectName;
+ }
+
+
+ @Override
+ public void mbeanRegistered(ObjectName objectName) throws Exception
+ {
+ if (objectName.equals(sampleServiceObjectName))
+ {
+ String value = getServiceBindingManager().getStringBinding(objectName.getCanonicalName(), null, "socket://${host}:${port}", "localhost", 9999);
+ MBeanServer server = getServer();
+ server.setAttribute(objectName, new Attribute("TestAttribute", value));
+ }
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfigurator.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfiguratorMBean.java
===================================================================
--- trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfiguratorMBean.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfiguratorMBean.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,40 +1,40 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jmx.examples.configuration;
-
-import javax.management.ObjectName;
-
-/**
- * StandardMBean interface for SampleMBeanConfigurator.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface SampleMBeanConfiguratorMBean extends MBeanConfiguratorSupportMBean
-{
-
- public abstract ObjectName getSampleServiceObjectName();
-
- public abstract void setSampleServiceObjectName(ObjectName sampleServiceObjectName);
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jmx.examples.configuration;
+
+import javax.management.ObjectName;
+
+/**
+ * StandardMBean interface for SampleMBeanConfigurator.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface SampleMBeanConfiguratorMBean extends MBeanConfiguratorSupportMBean
+{
+
+ public abstract ObjectName getSampleServiceObjectName();
+
+ public abstract void setSampleServiceObjectName(ObjectName sampleServiceObjectName);
+
}
\ No newline at end of file
Property changes on: trunk/varia/src/main/org/jboss/jmx/examples/configuration/SampleMBeanConfiguratorMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/mail/SessionObjectFactory.java
===================================================================
--- trunk/varia/src/main/org/jboss/mail/SessionObjectFactory.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/mail/SessionObjectFactory.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,81 +1,81 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.mail;
-
-import java.util.Hashtable;
-import java.util.Properties;
-
-import javax.mail.Authenticator;
-import javax.mail.Session;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.spi.ObjectFactory;
-
-/**
- * A jndi ObjectFactory implementation that creates a new Session from the
- * static class information on each getObjectInstance call.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SessionObjectFactory implements ObjectFactory
-{
- private static Properties props;
- private static Authenticator auth;
- private static Session instance;
- private static boolean shareSessionInstance;
-
- static void setSessionFactoryInfo(Properties props, Authenticator auth)
- {
- SessionObjectFactory.props = props;
- SessionObjectFactory.auth = auth;
- }
-
- static void setShareSessionInstance(boolean shareSessionInstance)
- {
- SessionObjectFactory.shareSessionInstance = shareSessionInstance;
- }
-
- public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable<?, ?> environment) throws Exception
- {
- Session session = null;
- if(shareSessionInstance)
- {
- initSession();
- session = instance;
- }
- else
- {
- session = Session.getInstance(props, auth);
- }
- return session;
- }
-
- static synchronized void initSession()
- {
- if(instance == null)
- {
- instance = Session.getInstance(props, auth);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.mail;
+
+import java.util.Hashtable;
+import java.util.Properties;
+
+import javax.mail.Authenticator;
+import javax.mail.Session;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+/**
+ * A jndi ObjectFactory implementation that creates a new Session from the
+ * static class information on each getObjectInstance call.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class SessionObjectFactory implements ObjectFactory
+{
+ private static Properties props;
+ private static Authenticator auth;
+ private static Session instance;
+ private static boolean shareSessionInstance;
+
+ static void setSessionFactoryInfo(Properties props, Authenticator auth)
+ {
+ SessionObjectFactory.props = props;
+ SessionObjectFactory.auth = auth;
+ }
+
+ static void setShareSessionInstance(boolean shareSessionInstance)
+ {
+ SessionObjectFactory.shareSessionInstance = shareSessionInstance;
+ }
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx,
+ Hashtable<?, ?> environment) throws Exception
+ {
+ Session session = null;
+ if(shareSessionInstance)
+ {
+ initSession();
+ session = instance;
+ }
+ else
+ {
+ session = Session.getInstance(props, auth);
+ }
+ return session;
+ }
+
+ static synchronized void initSession()
+ {
+ if(instance == null)
+ {
+ instance = Session.getInstance(props, auth);
+ }
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/mail/SessionObjectFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,42 +1,42 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-import org.w3c.dom.Element;
-
-/**
- * A {@link ServiceBindingValueSource} that returns an Element.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface ElementServiceBindingValueSource extends ServiceBindingValueSource
-{
- /**
- * Returns the String to use for the binding value.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @return an String to use as the binding value. May return <code>null</code>.
- */
- Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import org.w3c.dom.Element;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns an Element.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface ElementServiceBindingValueSource extends ServiceBindingValueSource
+{
+ /**
+ * Returns the String to use for the binding value.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @return an String to use as the binding value. May return <code>null</code>.
+ */
+ Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception;
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,43 +1,43 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-import java.net.InetAddress;
-
-/**
- * A {@link ServiceBindingValueSource} that returns an InetAddress. Typically used as
- * a source for a host binding value.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface InetAddressServiceBindingValueSource extends ServiceBindingValueSource
-{
- /**
- * Returns the InetAddress to use for the binding value.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @return an InetAddress to use as the binding value. May return <code>null</code>.
- */
- InetAddress getInetAddressServiceBindingValue(ServiceBinding binding) throws Exception;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import java.net.InetAddress;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns an InetAddress. Typically used as
+ * a source for a host binding value.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface InetAddressServiceBindingValueSource extends ServiceBindingValueSource
+{
+ /**
+ * Returns the InetAddress to use for the binding value.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @return an InetAddress to use as the binding value. May return <code>null</code>.
+ */
+ InetAddress getInetAddressServiceBindingValue(ServiceBinding binding) throws Exception;
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,41 +1,41 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-/**
- * A {@link ServiceBindingValueSource} that returns an int. Typically used as
- * a source for a port binding value.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface IntServiceBindingValueSource extends ServiceBindingValueSource
-{
- /**
- * Returns the int to use for the binding value.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @return an int to use as the binding value
- */
- int getIntServiceBindingValue(ServiceBinding binding) throws Exception;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns an int. Typically used as
+ * a source for a port binding value.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface IntServiceBindingValueSource extends ServiceBindingValueSource
+{
+ /**
+ * Returns the int to use for the binding value.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @return an int to use as the binding value
+ */
+ int getIntServiceBindingValue(ServiceBinding binding) throws Exception;
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,47 +1,47 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-/**
- * Exception thrown by {@link ServiceBindingManager} when no binding
- * can be found that matches a binding request.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class NoSuchBindingException extends Exception
-{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -9055052272112983527L;
-
- public NoSuchBindingException(String serverName, String serviceName, String bindingName)
- {
- this("No binding " + bindingName + " found for service " + serviceName + " in set " + serverName);
- }
-
- public NoSuchBindingException(String msg)
- {
- super(msg);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+/**
+ * Exception thrown by {@link ServiceBindingManager} when no binding
+ * can be found that matches a binding request.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class NoSuchBindingException extends Exception
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -9055052272112983527L;
+
+ public NoSuchBindingException(String serverName, String serviceName, String bindingName)
+ {
+ this("No binding " + bindingName + " found for service " + serviceName + " in set " + serverName);
+ }
+
+ public NoSuchBindingException(String msg)
+ {
+ super(msg);
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,145 +1,145 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.services.binding;
-
-import java.net.InetAddress;
-
-
-/** Interface for API to persist, read, and look up service configs
- *
- * @version $Revision: 37459 $
- * @author <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>.
- * @author Scott.Stark at jboss.org
- * @author Brian Stansberry
- */
-public interface ServiceBindingStore
-{
- /** Obtain a ServiceBinding object for the given server instance, target
- * service and binidng name. This is called by the JBoss service configuration
- * layer to obtain service attribute binding overrides.
- *
- * @param serverName the name identifying the JBoss server instance in
- * which the service is running.
- * @param serviceName the name of the service
- * @param bindingName the name of the binding, or <code>null</code> to indicate
- * the default binding.
- * @return the ServiceBinding if one exists for the <serverName, serviceName, bindingName>
- * tuple.
- *
- * @throws NoSuchBindingException if no matching binding exists
- */
- ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
- throws NoSuchBindingException;
-
- /**
- * Add a ServiceBinding to the store. This is an optional method not used
- * by the JBoss service configuration layer.
- *
- * @param serverName the name identifying the JBoss server instance in
- * which the service is running.
- * @param serviceName the JMX ObjectName of the service
- * @param serviceConfig the configuration to add
- *
- * @throws DuplicateServiceException thrown if a configuration for the
- * <serverName, serviceName> pair already exists.
- */
- void addServiceBinding(String serverName, ServiceBinding binding)
- throws DuplicateServiceException;
-
- /**
- * Remove a service configuration from the store. This is an optonal method
- * not used by the JBoss service configuration layer.
- *
- * @param serverName the name identifying the JBoss server instance in
- * which the service is running.
- * @param serviceBinding the binding
- */
- void removeServiceBinding(String serverName, ServiceBinding binding);
-
- /**
- * Remove a service configuration from the store. This is an optonal method
- * not used by the JBoss service configuration layer.
- *
- * @param serverName the name identifying the JBoss server instance in
- * which the service is running.
- * @param serviceBinding the binding
- */
- void removeServiceBinding(String serverName, String serviceName, String bindingName);
-
- /**
- * Add a ServiceBinding to all binding sets in the store. For each binding
- * set, a new ServiceBinding is added whose serviceName and bindingName
- * properties match the passed binding. The new binding's hostName matches
- * the target set's {@link #getDefaultHostName(String) default host name}.
- * The new binding's port is derived by taking the port from the passed
- * binding and incrementing it by the target set's
- * {@link #getDefaultPortOffset(String) default port offset}.
- *
- * @param serviceName the JMX ObjectName of the service
- * @param serviceConfig the configuration to add
- *
- * @throws DuplicateServiceException thrown if a configuration for the
- * <serverName, serviceName> pair already exists.
- */
- void addServiceBinding(ServiceBinding binding)
- throws DuplicateServiceException;
-
- /**
- * Remove a service configuration from all binding sets in the store.
- *
- * @param serviceBinding the binding
- */
- void removeServiceBinding(ServiceBinding binding);
-
- /**
- * Remove a service configuration from all binding sets in the store.
- *
- * @param serviceBinding the binding
- */
- void removeServiceBinding(String serviceName, String bindingName);
-
- /**
- * Gets the offset from a base value that by default should be added to
- * port values for a given serverName.
- *
- * @param serverName the name of the binding set
- * @return the offset
- */
- int getDefaultPortOffset(String serverName);
-
- /**
- * Gets the default value to use as the host name for the given serverName.
- *
- * @param serverName the name of the binding set
- * @return the host name
- */
- String getDefaultHostName(String serverName);
-
- /**
- * Value of <code>InetAddress.getByHost({@link #getDefaultHostName(String) getDefaultHost(serverName)})</code>.
- *
- * @param serverName the name of the binding set
- * @return the host name
- */
- InetAddress getDefaultBindAddress(String serverName);
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.services.binding;
+
+import java.net.InetAddress;
+
+
+/** Interface for API to persist, read, and look up service configs
+ *
+ * @version $Revision: 37459 $
+ * @author <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>.
+ * @author Scott.Stark at jboss.org
+ * @author Brian Stansberry
+ */
+public interface ServiceBindingStore
+{
+ /** Obtain a ServiceBinding object for the given server instance, target
+ * service and binidng name. This is called by the JBoss service configuration
+ * layer to obtain service attribute binding overrides.
+ *
+ * @param serverName the name identifying the JBoss server instance in
+ * which the service is running.
+ * @param serviceName the name of the service
+ * @param bindingName the name of the binding, or <code>null</code> to indicate
+ * the default binding.
+ * @return the ServiceBinding if one exists for the <serverName, serviceName, bindingName>
+ * tuple.
+ *
+ * @throws NoSuchBindingException if no matching binding exists
+ */
+ ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
+ throws NoSuchBindingException;
+
+ /**
+ * Add a ServiceBinding to the store. This is an optional method not used
+ * by the JBoss service configuration layer.
+ *
+ * @param serverName the name identifying the JBoss server instance in
+ * which the service is running.
+ * @param serviceName the JMX ObjectName of the service
+ * @param serviceConfig the configuration to add
+ *
+ * @throws DuplicateServiceException thrown if a configuration for the
+ * <serverName, serviceName> pair already exists.
+ */
+ void addServiceBinding(String serverName, ServiceBinding binding)
+ throws DuplicateServiceException;
+
+ /**
+ * Remove a service configuration from the store. This is an optonal method
+ * not used by the JBoss service configuration layer.
+ *
+ * @param serverName the name identifying the JBoss server instance in
+ * which the service is running.
+ * @param serviceBinding the binding
+ */
+ void removeServiceBinding(String serverName, ServiceBinding binding);
+
+ /**
+ * Remove a service configuration from the store. This is an optonal method
+ * not used by the JBoss service configuration layer.
+ *
+ * @param serverName the name identifying the JBoss server instance in
+ * which the service is running.
+ * @param serviceBinding the binding
+ */
+ void removeServiceBinding(String serverName, String serviceName, String bindingName);
+
+ /**
+ * Add a ServiceBinding to all binding sets in the store. For each binding
+ * set, a new ServiceBinding is added whose serviceName and bindingName
+ * properties match the passed binding. The new binding's hostName matches
+ * the target set's {@link #getDefaultHostName(String) default host name}.
+ * The new binding's port is derived by taking the port from the passed
+ * binding and incrementing it by the target set's
+ * {@link #getDefaultPortOffset(String) default port offset}.
+ *
+ * @param serviceName the JMX ObjectName of the service
+ * @param serviceConfig the configuration to add
+ *
+ * @throws DuplicateServiceException thrown if a configuration for the
+ * <serverName, serviceName> pair already exists.
+ */
+ void addServiceBinding(ServiceBinding binding)
+ throws DuplicateServiceException;
+
+ /**
+ * Remove a service configuration from all binding sets in the store.
+ *
+ * @param serviceBinding the binding
+ */
+ void removeServiceBinding(ServiceBinding binding);
+
+ /**
+ * Remove a service configuration from all binding sets in the store.
+ *
+ * @param serviceBinding the binding
+ */
+ void removeServiceBinding(String serviceName, String bindingName);
+
+ /**
+ * Gets the offset from a base value that by default should be added to
+ * port values for a given serverName.
+ *
+ * @param serverName the name of the binding set
+ * @return the offset
+ */
+ int getDefaultPortOffset(String serverName);
+
+ /**
+ * Gets the default value to use as the host name for the given serverName.
+ *
+ * @param serverName the name of the binding set
+ * @return the host name
+ */
+ String getDefaultHostName(String serverName);
+
+ /**
+ * Value of <code>InetAddress.getByHost({@link #getDefaultHostName(String) getDefaultHost(serverName)})</code>.
+ *
+ * @param serverName the name of the binding set
+ * @return the host name
+ */
+ InetAddress getDefaultBindAddress(String serverName);
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,46 +1,46 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.services.binding;
-
-
-/**
- * Source for a service binding value.
- *
- * @author Brian Stansberry
- */
-public interface ServiceBindingValueSource
-{
- /**
- * Returns a detyped binding value based on the provided binding
- * and detyped array of parameters.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @param params the parameters, or <code>null</code>
- *
- * @return the binding value. May return <code>null</code>
- *
- * @throws IllegalArgumentException if content of <code>params</code> is
- * not understood
- * @throws Exception if another exception occurs
- */
- public Object getServiceBindingValue(ServiceBinding binding, Object ... params) throws Exception;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.services.binding;
+
+
+/**
+ * Source for a service binding value.
+ *
+ * @author Brian Stansberry
+ */
+public interface ServiceBindingValueSource
+{
+ /**
+ * Returns a detyped binding value based on the provided binding
+ * and detyped array of parameters.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @param params the parameters, or <code>null</code>
+ *
+ * @return the binding value. May return <code>null</code>
+ *
+ * @throws IllegalArgumentException if content of <code>params</code> is
+ * not understood
+ * @throws Exception if another exception occurs
+ */
+ public Object getServiceBindingValue(ServiceBinding binding, Object ... params) throws Exception;
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,43 +1,43 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-
-/**
- * A {@link ServiceBindingValueSource} that returns a String.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface StringServiceBindingValueSource extends ServiceBindingValueSource
-{
- /**
- * Returns the String to use for the binding value.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @param originalValue an unprocessed value to which transformation can be applied
- *
- * @return an String to use as the binding value. May return <code>null</code>.
- */
- String getStringServiceBindingValue(ServiceBinding binding, String input) throws Exception;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+
+/**
+ * A {@link ServiceBindingValueSource} that returns a String.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface StringServiceBindingValueSource extends ServiceBindingValueSource
+{
+ /**
+ * Returns the String to use for the binding value.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @param originalValue an unprocessed value to which transformation can be applied
+ *
+ * @return an String to use as the binding value. May return <code>null</code>.
+ */
+ String getStringServiceBindingValue(ServiceBinding binding, String input) throws Exception;
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,102 +1,102 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Set;
-
-/**
- * Defines system properties for a given set of {@link SystemPropertyBinding}s
- * in its {@link #start()} phase, and clears them in its {@link #stop()} phase.
- * <p>
- * Intent is this service would be used as a utility to convert
- * {@link ServiceBindingManager} values into system properties so other
- * services could consume them without being aware of
- * <code>ServiceBindingManager</code>.
- * <p/>
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class SystemPropertyBinder
-{
- private final Set<SystemPropertyBinding> bindings;
-
- public SystemPropertyBinder(Set<SystemPropertyBinding> bindings)
- {
- this.bindings = bindings;
- }
-
- public void start()
- {
- for (SystemPropertyBinding binding : bindings)
- {
- final String property = binding.getProperty();
- final String value = binding.getValue();
-
- if (System.getSecurityManager() == null)
- {
- System.setProperty(property, value);
- }
- else
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
-
- public Object run()
- {
- System.setProperty(property, value);
- return null;
- }
-
- });
- }
- }
-
- }
-
- public void stop()
- {
- for (SystemPropertyBinding binding : bindings)
- {
- final String property = binding.getProperty();
-
- if (System.getSecurityManager() == null)
- {
- System.clearProperty(property);
- }
- else
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
-
- public Object run()
- {
- System.clearProperty(property);
- return null;
- }
-
- });
- }
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Set;
+
+/**
+ * Defines system properties for a given set of {@link SystemPropertyBinding}s
+ * in its {@link #start()} phase, and clears them in its {@link #stop()} phase.
+ * <p>
+ * Intent is this service would be used as a utility to convert
+ * {@link ServiceBindingManager} values into system properties so other
+ * services could consume them without being aware of
+ * <code>ServiceBindingManager</code>.
+ * <p/>
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SystemPropertyBinder
+{
+ private final Set<SystemPropertyBinding> bindings;
+
+ public SystemPropertyBinder(Set<SystemPropertyBinding> bindings)
+ {
+ this.bindings = bindings;
+ }
+
+ public void start()
+ {
+ for (SystemPropertyBinding binding : bindings)
+ {
+ final String property = binding.getProperty();
+ final String value = binding.getValue();
+
+ if (System.getSecurityManager() == null)
+ {
+ System.setProperty(property, value);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+ public Object run()
+ {
+ System.setProperty(property, value);
+ return null;
+ }
+
+ });
+ }
+ }
+
+ }
+
+ public void stop()
+ {
+ for (SystemPropertyBinding binding : bindings)
+ {
+ final String property = binding.getProperty();
+
+ if (System.getSecurityManager() == null)
+ {
+ System.clearProperty(property);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+ public Object run()
+ {
+ System.clearProperty(property);
+ return null;
+ }
+
+ });
+ }
+ }
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,73 +1,73 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-import java.net.InetAddress;
-import java.net.URL;
-
-/**
- * Encapsulates the key and value for a system property. Basic function is to
- * perform type conversions in its constructor for values returned by
- * {@link ServiceBindingManager} so {@link SystemPropertyBinder} can bind the
- * values.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class SystemPropertyBinding
-{
- private final String property;
- private final String value;
-
- public SystemPropertyBinding(String property, int value)
- {
- this(property, String.valueOf(value));
- }
-
- public SystemPropertyBinding(String property, InetAddress value)
- {
- this(property, value.getHostAddress());
- }
-
- public SystemPropertyBinding(String property, URL value)
- {
- this(property, value.toExternalForm());
- }
-
- public SystemPropertyBinding(String property, String value)
- {
- this.property = property;
- this.value = value;
- }
-
- public String getProperty()
- {
- return property;
- }
- public String getValue()
- {
- return value;
- }
-
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import java.net.InetAddress;
+import java.net.URL;
+
+/**
+ * Encapsulates the key and value for a system property. Basic function is to
+ * perform type conversions in its constructor for values returned by
+ * {@link ServiceBindingManager} so {@link SystemPropertyBinder} can bind the
+ * values.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SystemPropertyBinding
+{
+ private final String property;
+ private final String value;
+
+ public SystemPropertyBinding(String property, int value)
+ {
+ this(property, String.valueOf(value));
+ }
+
+ public SystemPropertyBinding(String property, InetAddress value)
+ {
+ this(property, value.getHostAddress());
+ }
+
+ public SystemPropertyBinding(String property, URL value)
+ {
+ this(property, value.toExternalForm());
+ }
+
+ public SystemPropertyBinding(String property, String value)
+ {
+ this.property = property;
+ this.value = value;
+ }
+
+ public String getProperty()
+ {
+ return property;
+ }
+ public String getValue()
+ {
+ return value;
+ }
+
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,60 +1,60 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding;
-
-import java.net.URL;
-
-/**
- * A {@link ServiceBindingValueSource} that returns a URL or a String
- * representation of one.
- * <p>
- * Typical usage is in file transformation operations, where a given
- * the content of a given <code>input</code> URL or classpath resource is read,
- * transformed, written to a temp file, and the URL of the temp file returned.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface URLServiceBindingValueSource extends ServiceBindingValueSource
-{
- /**
- * Returns the URL to use for the binding value.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @param input the URL to use as input data
- *
- * @return a URL to use as the binding value. Will not return <code>null</code>.
- */
- URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception;
-
- /**
- * Returns a String representation of a URL path to use for the binding value.
- *
- * @param binding the binding. Cannot be <code>null</code>
- * @param input either a String representation of a URL or a value that
- * can be passed to {@link ClassLoader#getResourceAsStream(String)}
- *
- * @return a filesystem path to use as the binding value. May return <code>null</code>.
- */
- String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import java.net.URL;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns a URL or a String
+ * representation of one.
+ * <p>
+ * Typical usage is in file transformation operations, where a given
+ * the content of a given <code>input</code> URL or classpath resource is read,
+ * transformed, written to a temp file, and the URL of the temp file returned.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface URLServiceBindingValueSource extends ServiceBindingValueSource
+{
+ /**
+ * Returns the URL to use for the binding value.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @param input the URL to use as input data
+ *
+ * @return a URL to use as the binding value. Will not return <code>null</code>.
+ */
+ URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception;
+
+ /**
+ * Returns a String representation of a URL path to use for the binding value.
+ *
+ * @param binding the binding. Cannot be <code>null</code>
+ * @param input either a String representation of a URL or a value that
+ * can be passed to {@link ClassLoader#getResourceAsStream(String)}
+ *
+ * @return a filesystem path to use as the binding value. May return <code>null</code>.
+ */
+ String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception;
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,228 +1,228 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.jboss.services.binding.DuplicateServiceException;
-import org.jboss.services.binding.NoSuchBindingException;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingStore;
-
-/**
- * A PojoServiceBindingStore.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class PojoServiceBindingStore implements ServiceBindingStore
-{
- private static final Object VALUE = new Object();
-
- private final ConcurrentMap<ServiceBindingKey, ServiceBinding> bindings =
- new ConcurrentHashMap<ServiceBindingKey, ServiceBinding>(16, (float) .75, 4);
-
- private final ConcurrentMap<String, Object> bindingSetNames =
- new ConcurrentHashMap<String, Object>(16, (float) .75, 4);
-
- private final Map<String, String> defaultHostNames = new HashMap<String, String>();
-
- private final Map<String, InetAddress> defaultBindAddresses = new HashMap<String, InetAddress>();
-
- private final Map<String, Integer> defaultPortOffsets = new HashMap<String, Integer>();
-
- public PojoServiceBindingStore(Map<String, ServiceBindingSet> configSets)
- throws DuplicateServiceException
- {
- if (configSets == null)
- throw new IllegalArgumentException("configSets is null");
-
- for (Map.Entry<String, ServiceBindingSet> entry : configSets.entrySet())
- {
- String serverName = entry.getKey();
-
- bindingSetNames.put(serverName, VALUE);
-
- ServiceBindingSet bindingSet = entry.getValue();
-
- defaultHostNames.put(serverName, bindingSet.getDefaultHostName());
- defaultBindAddresses.put(serverName, bindingSet.getDefaultBindAddress());
- defaultPortOffsets.put(serverName, bindingSet.getPortOffset());
-
- for (ServiceBinding binding : bindingSet)
- {
- addServiceBinding(serverName, binding);
- }
- }
- }
-
- public void addServiceBinding(String serverName, ServiceBinding binding) throws DuplicateServiceException
- {
- validateServerName(serverName);
- Object oldBinding = bindings.putIfAbsent(new ServiceBindingKey(serverName, binding), binding);
- if (oldBinding != null)
- {
- throw new DuplicateServiceException(serverName, binding);
- }
- }
-
- public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
- throws NoSuchBindingException
- {
- ServiceBinding binding = bindings.get(new ServiceBindingKey(serverName, serviceName, bindingName));
- if (binding == null)
- {
- throw new NoSuchBindingException(serverName, serviceName, bindingName);
- }
- return binding;
- }
-
- public void removeServiceBinding(String serverName, ServiceBinding binding)
- {
- validateServerName(serverName);
- bindings.remove(new ServiceBindingKey(serverName, binding));
- }
-
- public void removeServiceBinding(String serverName, String serviceName, String bindingName)
- {
- validateServerName(serverName);
- bindings.remove(new ServiceBindingKey(serverName, serviceName, bindingName));
- }
-
- public void addServiceBinding(ServiceBinding binding) throws DuplicateServiceException
- {
- for (String serverName : bindingSetNames.keySet())
- {
- int port = binding.getPort() + getDefaultPortOffset(serverName);
- String hostName = binding.getHostName();
- if (hostName == null)
- hostName = getDefaultHostName(serverName);
-
- try
- {
- addServiceBinding(serverName, new ServiceBinding(binding.getServiceName(), binding.getBindingName(), hostName, port));
- }
- catch (UnknownHostException e)
- {
- throw new IllegalStateException("Cannot convert " + hostName + " into an InetAddress");
- }
- }
- }
-
- public void removeServiceBinding(ServiceBinding binding)
- {
- for (String serverName : bindingSetNames.keySet())
- {
- removeServiceBinding(serverName, binding);
- }
- }
-
- public void removeServiceBinding(String serviceName, String bindingName)
- {
- for (String serverName : bindingSetNames.keySet())
- {
- removeServiceBinding(serverName, serviceName, bindingName);
- }
- }
-
- public InetAddress getDefaultBindAddress(String serverName)
- {
- validateServerName(serverName);
- return defaultBindAddresses.get(serverName);
- }
-
- public String getDefaultHostName(String serverName)
- {
- validateServerName(serverName);
- return defaultHostNames.get(serverName);
- }
-
- public int getDefaultPortOffset(String serverName)
- {
- validateServerName(serverName);
- return defaultPortOffsets.get(serverName).intValue();
- }
-
- private void validateServerName(String serverName)
- {
- if (bindingSetNames.containsKey(serverName) == false)
- throw new IllegalArgumentException("unknown serverName " +serverName);
- }
-
- private static class ServiceBindingKey
- {
- private final String serverName;
- private final String serviceName;
- private final String bindingName;
-
- private ServiceBindingKey(String serverName, ServiceBinding binding)
- {
- this(serverName, binding.getServiceName(), binding.getBindingName());
- }
-
- private ServiceBindingKey(String serverName, String serviceName, String bindingName)
- {
- assert serverName != null : "serverName is null";
- assert serviceName != null : "serviceName is null";
-
- this.serverName = serverName;
- this.serviceName = ServiceBinding.canonicalizeServiceName(serviceName);
- this.bindingName = bindingName;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof ServiceBindingKey)
- {
- ServiceBindingKey other = (ServiceBindingKey) obj;
- return (this.serverName.equals(other.serverName)
- && this.serviceName.equals(other.serviceName)
- && safeEquals(this.bindingName, other.bindingName));
- }
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int result = 17;
- result += 23 * this.serverName.hashCode();
- result += 23 * this.serviceName.hashCode();
- result += 23 * (this.bindingName == null ? 0 : this.bindingName.hashCode());
- return result;
- }
-
- private boolean safeEquals(Object a, Object b)
- {
- return (a == b || (a != null && a.equals(b)));
- }
-
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.services.binding.DuplicateServiceException;
+import org.jboss.services.binding.NoSuchBindingException;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingStore;
+
+/**
+ * A PojoServiceBindingStore.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class PojoServiceBindingStore implements ServiceBindingStore
+{
+ private static final Object VALUE = new Object();
+
+ private final ConcurrentMap<ServiceBindingKey, ServiceBinding> bindings =
+ new ConcurrentHashMap<ServiceBindingKey, ServiceBinding>(16, (float) .75, 4);
+
+ private final ConcurrentMap<String, Object> bindingSetNames =
+ new ConcurrentHashMap<String, Object>(16, (float) .75, 4);
+
+ private final Map<String, String> defaultHostNames = new HashMap<String, String>();
+
+ private final Map<String, InetAddress> defaultBindAddresses = new HashMap<String, InetAddress>();
+
+ private final Map<String, Integer> defaultPortOffsets = new HashMap<String, Integer>();
+
+ public PojoServiceBindingStore(Map<String, ServiceBindingSet> configSets)
+ throws DuplicateServiceException
+ {
+ if (configSets == null)
+ throw new IllegalArgumentException("configSets is null");
+
+ for (Map.Entry<String, ServiceBindingSet> entry : configSets.entrySet())
+ {
+ String serverName = entry.getKey();
+
+ bindingSetNames.put(serverName, VALUE);
+
+ ServiceBindingSet bindingSet = entry.getValue();
+
+ defaultHostNames.put(serverName, bindingSet.getDefaultHostName());
+ defaultBindAddresses.put(serverName, bindingSet.getDefaultBindAddress());
+ defaultPortOffsets.put(serverName, bindingSet.getPortOffset());
+
+ for (ServiceBinding binding : bindingSet)
+ {
+ addServiceBinding(serverName, binding);
+ }
+ }
+ }
+
+ public void addServiceBinding(String serverName, ServiceBinding binding) throws DuplicateServiceException
+ {
+ validateServerName(serverName);
+ Object oldBinding = bindings.putIfAbsent(new ServiceBindingKey(serverName, binding), binding);
+ if (oldBinding != null)
+ {
+ throw new DuplicateServiceException(serverName, binding);
+ }
+ }
+
+ public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
+ throws NoSuchBindingException
+ {
+ ServiceBinding binding = bindings.get(new ServiceBindingKey(serverName, serviceName, bindingName));
+ if (binding == null)
+ {
+ throw new NoSuchBindingException(serverName, serviceName, bindingName);
+ }
+ return binding;
+ }
+
+ public void removeServiceBinding(String serverName, ServiceBinding binding)
+ {
+ validateServerName(serverName);
+ bindings.remove(new ServiceBindingKey(serverName, binding));
+ }
+
+ public void removeServiceBinding(String serverName, String serviceName, String bindingName)
+ {
+ validateServerName(serverName);
+ bindings.remove(new ServiceBindingKey(serverName, serviceName, bindingName));
+ }
+
+ public void addServiceBinding(ServiceBinding binding) throws DuplicateServiceException
+ {
+ for (String serverName : bindingSetNames.keySet())
+ {
+ int port = binding.getPort() + getDefaultPortOffset(serverName);
+ String hostName = binding.getHostName();
+ if (hostName == null)
+ hostName = getDefaultHostName(serverName);
+
+ try
+ {
+ addServiceBinding(serverName, new ServiceBinding(binding.getServiceName(), binding.getBindingName(), hostName, port));
+ }
+ catch (UnknownHostException e)
+ {
+ throw new IllegalStateException("Cannot convert " + hostName + " into an InetAddress");
+ }
+ }
+ }
+
+ public void removeServiceBinding(ServiceBinding binding)
+ {
+ for (String serverName : bindingSetNames.keySet())
+ {
+ removeServiceBinding(serverName, binding);
+ }
+ }
+
+ public void removeServiceBinding(String serviceName, String bindingName)
+ {
+ for (String serverName : bindingSetNames.keySet())
+ {
+ removeServiceBinding(serverName, serviceName, bindingName);
+ }
+ }
+
+ public InetAddress getDefaultBindAddress(String serverName)
+ {
+ validateServerName(serverName);
+ return defaultBindAddresses.get(serverName);
+ }
+
+ public String getDefaultHostName(String serverName)
+ {
+ validateServerName(serverName);
+ return defaultHostNames.get(serverName);
+ }
+
+ public int getDefaultPortOffset(String serverName)
+ {
+ validateServerName(serverName);
+ return defaultPortOffsets.get(serverName).intValue();
+ }
+
+ private void validateServerName(String serverName)
+ {
+ if (bindingSetNames.containsKey(serverName) == false)
+ throw new IllegalArgumentException("unknown serverName " +serverName);
+ }
+
+ private static class ServiceBindingKey
+ {
+ private final String serverName;
+ private final String serviceName;
+ private final String bindingName;
+
+ private ServiceBindingKey(String serverName, ServiceBinding binding)
+ {
+ this(serverName, binding.getServiceName(), binding.getBindingName());
+ }
+
+ private ServiceBindingKey(String serverName, String serviceName, String bindingName)
+ {
+ assert serverName != null : "serverName is null";
+ assert serviceName != null : "serviceName is null";
+
+ this.serverName = serverName;
+ this.serviceName = ServiceBinding.canonicalizeServiceName(serviceName);
+ this.bindingName = bindingName;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ServiceBindingKey)
+ {
+ ServiceBindingKey other = (ServiceBindingKey) obj;
+ return (this.serverName.equals(other.serverName)
+ && this.serviceName.equals(other.serviceName)
+ && safeEquals(this.bindingName, other.bindingName));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 17;
+ result += 23 * this.serverName.hashCode();
+ result += 23 * this.serviceName.hashCode();
+ result += 23 * (this.bindingName == null ? 0 : this.bindingName.hashCode());
+ return result;
+ }
+
+ private boolean safeEquals(Object a, Object b)
+ {
+ return (a == b || (a != null && a.equals(b)));
+ }
+
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,106 +1,106 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.services.binding.ServiceBinding;
-
-/**
- * Set<ServiceBinding> that populates itself by taking a base set
- * and duplicating its binding with a fixed offset to each port value.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class ServiceBindingSet extends HashSet<ServiceBinding>
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 765380451233486038L;
-
- private final String defaultHostName;
- private final InetAddress defaultBindAddress;
- private final int portOffset;
-
- public ServiceBindingSet(Set<ServiceBinding> base) throws UnknownHostException
- {
- this(base, 0, null, null);
- }
-
- public ServiceBindingSet(Set<ServiceBinding> base, int offset) throws UnknownHostException
- {
- this(base, offset, null, null);
- }
-
- public ServiceBindingSet(Set<ServiceBinding> base, int offset, String defaultHostName) throws UnknownHostException
- {
- this(base, offset, null, defaultHostName);
- }
-
- public ServiceBindingSet(Set<ServiceBinding> base, int offset, Set<ServiceBinding> overrides, String defaultHostName) throws UnknownHostException
- {
- super(getOffsetBindings(base, offset));
- if (overrides != null)
- {
- // HashSet.add() is not a replace operation, so must remove first
- for (ServiceBinding binding : overrides)
- {
- remove(binding);
- add(binding);
- }
- }
-
- this.defaultHostName = defaultHostName;
- this.defaultBindAddress = defaultHostName == null ? null : InetAddress.getByName(defaultHostName);
- this.portOffset = offset;
- }
-
- private static Set<ServiceBinding> getOffsetBindings(Set<ServiceBinding> base, int offset) throws UnknownHostException
- {
- Set<ServiceBinding> altered = new HashSet<ServiceBinding>(base.size());
- for (ServiceBinding binding : base)
- {
- altered.add(binding.getOffsetBinding(offset));
- }
- return altered;
- }
-
- public String getDefaultHostName()
- {
- return defaultHostName;
- }
-
- public InetAddress getDefaultBindAddress()
- {
- return defaultBindAddress;
- }
-
- public int getPortOffset()
- {
- return portOffset;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.services.binding.ServiceBinding;
+
+/**
+ * Set<ServiceBinding> that populates itself by taking a base set
+ * and duplicating its binding with a fixed offset to each port value.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class ServiceBindingSet extends HashSet<ServiceBinding>
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 765380451233486038L;
+
+ private final String defaultHostName;
+ private final InetAddress defaultBindAddress;
+ private final int portOffset;
+
+ public ServiceBindingSet(Set<ServiceBinding> base) throws UnknownHostException
+ {
+ this(base, 0, null, null);
+ }
+
+ public ServiceBindingSet(Set<ServiceBinding> base, int offset) throws UnknownHostException
+ {
+ this(base, offset, null, null);
+ }
+
+ public ServiceBindingSet(Set<ServiceBinding> base, int offset, String defaultHostName) throws UnknownHostException
+ {
+ this(base, offset, null, defaultHostName);
+ }
+
+ public ServiceBindingSet(Set<ServiceBinding> base, int offset, Set<ServiceBinding> overrides, String defaultHostName) throws UnknownHostException
+ {
+ super(getOffsetBindings(base, offset));
+ if (overrides != null)
+ {
+ // HashSet.add() is not a replace operation, so must remove first
+ for (ServiceBinding binding : overrides)
+ {
+ remove(binding);
+ add(binding);
+ }
+ }
+
+ this.defaultHostName = defaultHostName;
+ this.defaultBindAddress = defaultHostName == null ? null : InetAddress.getByName(defaultHostName);
+ this.portOffset = offset;
+ }
+
+ private static Set<ServiceBinding> getOffsetBindings(Set<ServiceBinding> base, int offset) throws UnknownHostException
+ {
+ Set<ServiceBinding> altered = new HashSet<ServiceBinding>(base.size());
+ for (ServiceBinding binding : base)
+ {
+ altered.add(binding.getOffsetBinding(offset));
+ }
+ return altered;
+ }
+
+ public String getDefaultHostName()
+ {
+ return defaultHostName;
+ }
+
+ public InetAddress getDefaultBindAddress()
+ {
+ return defaultBindAddress;
+ }
+
+ public int getPortOffset()
+ {
+ return portOffset;
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,72 +1,72 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.net.InetAddress;
-
-import org.jboss.services.binding.InetAddressServiceBindingValueSource;
-import org.jboss.services.binding.IntServiceBindingValueSource;
-import org.jboss.services.binding.ServiceBinding;
-
-/**
- * ServiceBindingValueSource that returns the given binding's
- * {@link ServiceBinding#getBindAddress() bind address} and
- * {@link ServiceBinding#getPort() port}.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class SimpleServiceBindingValueSourceImpl
- implements
- IntServiceBindingValueSource,
- InetAddressServiceBindingValueSource
-{
-
- /**
- * @return <code>binding.{@link ServiceBinding#getPort() getPort()}</code>
- */
- public int getIntServiceBindingValue(ServiceBinding binding)
- {
- return binding.getPort();
- }
-
- /**
- * @return <code>binding.{@link ServiceBinding#getBindAddress() getBindAddress()}</code>
- */
- public InetAddress getInetAddressServiceBindingValue(ServiceBinding binding)
- {
- return binding.getBindAddress();
- }
-
- /**
- * @return <code>new Integer(binding.{@link ServiceBinding#getPort() getPort()})</code>
- */
- public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
- {
- if (params != null && params.length > 0)
- throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() does not accept argument 'params'");
-
- return new Integer(getIntServiceBindingValue(binding));
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.net.InetAddress;
+
+import org.jboss.services.binding.InetAddressServiceBindingValueSource;
+import org.jboss.services.binding.IntServiceBindingValueSource;
+import org.jboss.services.binding.ServiceBinding;
+
+/**
+ * ServiceBindingValueSource that returns the given binding's
+ * {@link ServiceBinding#getBindAddress() bind address} and
+ * {@link ServiceBinding#getPort() port}.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SimpleServiceBindingValueSourceImpl
+ implements
+ IntServiceBindingValueSource,
+ InetAddressServiceBindingValueSource
+{
+
+ /**
+ * @return <code>binding.{@link ServiceBinding#getPort() getPort()}</code>
+ */
+ public int getIntServiceBindingValue(ServiceBinding binding)
+ {
+ return binding.getPort();
+ }
+
+ /**
+ * @return <code>binding.{@link ServiceBinding#getBindAddress() getBindAddress()}</code>
+ */
+ public InetAddress getInetAddressServiceBindingValue(ServiceBinding binding)
+ {
+ return binding.getBindAddress();
+ }
+
+ /**
+ * @return <code>new Integer(binding.{@link ServiceBinding#getPort() getPort()})</code>
+ */
+ public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+ {
+ if (params != null && params.length > 0)
+ throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() does not accept argument 'params'");
+
+ return new Integer(getIntServiceBindingValue(binding));
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,61 +1,61 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-
-/**
- * A StringReplacementServiceBindingValueSourceConfig.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class StringReplacementServiceBindingValueSourceConfig
-{
- public static final String DEFAULT_HOST_MARKER = "${host}";
- public static final String DEFAULT_PORT_MARKER = "${port}";
-
- private String portMarker;
- private String hostMarker;
-
- public StringReplacementServiceBindingValueSourceConfig()
- {
- this(DEFAULT_HOST_MARKER, DEFAULT_PORT_MARKER);
- }
-
- public StringReplacementServiceBindingValueSourceConfig(String hostMarker, String portMarker)
- {
- this.hostMarker = (hostMarker == null ? DEFAULT_HOST_MARKER : hostMarker);
- this.portMarker = (portMarker == null ? DEFAULT_PORT_MARKER : portMarker);
- }
-
- public String getPortMarker()
- {
- return portMarker;
- }
-
- public String getHostMarker()
- {
- return hostMarker;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+
+/**
+ * A StringReplacementServiceBindingValueSourceConfig.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class StringReplacementServiceBindingValueSourceConfig
+{
+ public static final String DEFAULT_HOST_MARKER = "${host}";
+ public static final String DEFAULT_PORT_MARKER = "${port}";
+
+ private String portMarker;
+ private String hostMarker;
+
+ public StringReplacementServiceBindingValueSourceConfig()
+ {
+ this(DEFAULT_HOST_MARKER, DEFAULT_PORT_MARKER);
+ }
+
+ public StringReplacementServiceBindingValueSourceConfig(String hostMarker, String portMarker)
+ {
+ this.hostMarker = (hostMarker == null ? DEFAULT_HOST_MARKER : hostMarker);
+ this.portMarker = (portMarker == null ? DEFAULT_PORT_MARKER : portMarker);
+ }
+
+ public String getPortMarker()
+ {
+ return portMarker;
+ }
+
+ public String getHostMarker()
+ {
+ return hostMarker;
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,159 +1,159 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.net.URL;
-
-import org.jboss.services.binding.ElementServiceBindingValueSource;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.StringServiceBindingValueSource;
-import org.jboss.services.binding.URLServiceBindingValueSource;
-import org.w3c.dom.Element;
-
-/**
- * A StringReplacementServiceBindingValueSourceImpl.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class StringReplacementServiceBindingValueSourceImpl
- implements StringServiceBindingValueSource, ElementServiceBindingValueSource, URLServiceBindingValueSource
-{
-
- public String getStringServiceBindingValue(ServiceBinding binding, String input) throws Exception
- {
- if (input == null)
- {
- return binding.getHostName();
- }
-
- StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
- return replaceHostAndPort(input, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
- }
-
-
- public Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception
- {
- if (input == null)
- throw new IllegalArgumentException("input cannot be null");
-
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- if (editor == null)
- throw new IllegalStateException("Cannot find PropertyEditor for type Element");
-
- StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
-
- editor.setValue(input);
- String text = editor.getAsText();
- text = replaceHostAndPort(text, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
- editor.setAsText(text);
- return (Element) editor.getValue();
- }
-
- public String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception
- {
- if (input == null)
- throw new IllegalArgumentException("input cannot be null");
-
- StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
-
- String content = Util.getContentAsString(input);
- String transformed = replaceHostAndPort(content, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
- return Util.writeToTempFile(transformed).getAbsolutePath();
- }
-
-
- public URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception
- {
- if (input == null)
- throw new IllegalArgumentException("input cannot be null");
-
- StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
-
- String content = Util.getContentAsString(input);
- String transformed = replaceHostAndPort(content, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
- return Util.writeToTempFile(transformed).toURL();
- }
-
- public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
- {
- if (params == null)
- {
- return getStringServiceBindingValue(binding, null);
- }
-
- if (params.length != 1)
- {
- throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params'");
- }
-
- if (params[0] instanceof String)
- {
- return getStringServiceBindingValue(binding, (String) params[0]);
- }
- else if (params[0] instanceof Element)
- {
- return getElementServiceBindingValue(binding, (Element) params[0]);
- }
- else if (params[0] instanceof URL)
- {
- return getURLServiceBindingValue(binding, (URL) params[0]);
- }
-
- throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params' of type String, Element or URL");
- }
-
-
-
- // ---------------------------------------------------------------- Private
-
-
- private StringReplacementServiceBindingValueSourceConfig getConfig(ServiceBinding binding)
- {
- Object configSource = binding.getServiceBindingValueSourceConfig();
- if (configSource instanceof StringReplacementServiceBindingValueSourceConfig)
- {
- return (StringReplacementServiceBindingValueSourceConfig) configSource;
- }
- else
- {
- return new StringReplacementServiceBindingValueSourceConfig();
- }
- }
-
- private String replaceHostAndPort(String text, String host, int port, String hostMarker, String portMarker)
- {
- if( text == null )
- return null;
-
- if( host == null )
- host = "localhost";
- String portStr = String.valueOf(port);
-
- text = text.replace(hostMarker, host);
- return text.replace(portMarker, portStr);
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.net.URL;
+
+import org.jboss.services.binding.ElementServiceBindingValueSource;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.StringServiceBindingValueSource;
+import org.jboss.services.binding.URLServiceBindingValueSource;
+import org.w3c.dom.Element;
+
+/**
+ * A StringReplacementServiceBindingValueSourceImpl.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class StringReplacementServiceBindingValueSourceImpl
+ implements StringServiceBindingValueSource, ElementServiceBindingValueSource, URLServiceBindingValueSource
+{
+
+ public String getStringServiceBindingValue(ServiceBinding binding, String input) throws Exception
+ {
+ if (input == null)
+ {
+ return binding.getHostName();
+ }
+
+ StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
+ return replaceHostAndPort(input, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+ }
+
+
+ public Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception
+ {
+ if (input == null)
+ throw new IllegalArgumentException("input cannot be null");
+
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ if (editor == null)
+ throw new IllegalStateException("Cannot find PropertyEditor for type Element");
+
+ StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
+
+ editor.setValue(input);
+ String text = editor.getAsText();
+ text = replaceHostAndPort(text, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+ editor.setAsText(text);
+ return (Element) editor.getValue();
+ }
+
+ public String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception
+ {
+ if (input == null)
+ throw new IllegalArgumentException("input cannot be null");
+
+ StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
+
+ String content = Util.getContentAsString(input);
+ String transformed = replaceHostAndPort(content, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+ return Util.writeToTempFile(transformed).getAbsolutePath();
+ }
+
+
+ public URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception
+ {
+ if (input == null)
+ throw new IllegalArgumentException("input cannot be null");
+
+ StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
+
+ String content = Util.getContentAsString(input);
+ String transformed = replaceHostAndPort(content, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+ return Util.writeToTempFile(transformed).toURL();
+ }
+
+ public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+ {
+ if (params == null)
+ {
+ return getStringServiceBindingValue(binding, null);
+ }
+
+ if (params.length != 1)
+ {
+ throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params'");
+ }
+
+ if (params[0] instanceof String)
+ {
+ return getStringServiceBindingValue(binding, (String) params[0]);
+ }
+ else if (params[0] instanceof Element)
+ {
+ return getElementServiceBindingValue(binding, (Element) params[0]);
+ }
+ else if (params[0] instanceof URL)
+ {
+ return getURLServiceBindingValue(binding, (URL) params[0]);
+ }
+
+ throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params' of type String, Element or URL");
+ }
+
+
+
+ // ---------------------------------------------------------------- Private
+
+
+ private StringReplacementServiceBindingValueSourceConfig getConfig(ServiceBinding binding)
+ {
+ Object configSource = binding.getServiceBindingValueSourceConfig();
+ if (configSource instanceof StringReplacementServiceBindingValueSourceConfig)
+ {
+ return (StringReplacementServiceBindingValueSourceConfig) configSource;
+ }
+ else
+ {
+ return new StringReplacementServiceBindingValueSourceConfig();
+ }
+ }
+
+ private String replaceHostAndPort(String text, String host, int port, String hostMarker, String portMarker)
+ {
+ if( text == null )
+ return null;
+
+ if( host == null )
+ host = "localhost";
+ String portStr = String.valueOf(port);
+
+ text = text.replace(hostMarker, host);
+ return text.replace(portMarker, portStr);
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/Util.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/Util.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/Util.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,180 +1,180 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingValueSource;
-
-/**
- * Utilities used by service binding manager components.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class Util
-{
-
- public static InputStream getInputStream(URL url) throws IOException
- {
- URLConnection conn = url.openConnection();
- conn.connect();
- return conn.getInputStream();
- }
-
- public static InputStream getInputStream(String resource) throws IOException
- {
- try
- {
- URL url = new URL(resource);
- return getInputStream(url);
- }
- catch (MalformedURLException mue)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return cl.getResourceAsStream(resource);
- }
- }
-
- public static InputStreamReader getInputStreamReader(URL url) throws IOException
- {
- return new InputStreamReader(getInputStream(url));
- }
-
- public static InputStreamReader getInputStreamReader(String resource) throws IOException
- {
- try
- {
- URL url = new URL(resource);
- return getInputStreamReader(url);
- }
- catch (MalformedURLException mue)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream is = cl.getResourceAsStream(resource);
- if (is == null)
- throw new IllegalArgumentException("No resource " + resource + " found");
- return new InputStreamReader(is);
- }
- }
-
- public static String getContentAsString(URL url) throws IOException
- {
- InputStreamReader isr = getInputStreamReader(url);
- return getContentAsString(isr);
- }
-
- public static String getContentAsString(String resource) throws IOException
- {
- InputStreamReader isr = getInputStreamReader(resource);
- return getContentAsString(isr);
- }
-
- public static File writeToTempFile(String content) throws IOException
- {
- File targetFile = Util.createTempFile();
- OutputStreamWriter osw = null;
- try
- {
- osw = new OutputStreamWriter(new FileOutputStream(targetFile));
- osw.write(content);
-
- return targetFile;
- }
- finally
- {
- if (osw != null)
- osw.close();
- }
- }
-
- private static String getContentAsString(InputStreamReader isr) throws IOException
- {
- try
- {
- StringWriter writer = new StringWriter();
- char[] buf = new char[1024];
- int read;
- while((read = isr.read(buf, 0, buf.length)) != -1)
- {
- writer.write(buf, 0, read);
- }
- return writer.toString();
- }
- finally
- {
- isr.close();
- }
- }
-
- public static File createTempFile() throws IOException
- {
- String tmpName = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
- File tempDirectory = new File(tmpName);
- File targetFile = File.createTempFile("service-binding", ".tmp", tempDirectory);
- targetFile.deleteOnExit();
-
- return targetFile;
- }
-
- public static <T> T getBindingValue(ServiceBindingValueSource source, ServiceBinding binding, Class<T> expectedType) throws Exception
- {
- Object[] params = null;
- Object obj = source.getServiceBindingValue(binding, params);
- if (expectedType.isAssignableFrom(obj.getClass()))
- {
- return expectedType.cast(obj);
- }
- else
- {
- throw new IllegalStateException("Incompatible value source for " + binding + " -- must return " + expectedType.getSimpleName());
- }
- }
-
- public static <T> T getBindingValueWithInput(ServiceBindingValueSource source, ServiceBinding binding, Object input, Class<T> expectedType) throws Exception
- {
- Object obj = source.getServiceBindingValue(binding, input);
- if (expectedType.isAssignableFrom(obj.getClass()))
- {
- return expectedType.cast(obj);
- }
- else
- {
- throw new IllegalStateException("Incompatible value source for " + binding + " -- must return " + expectedType.getSimpleName());
- }
- }
-
- /** Prevent instantiation */
- private Util() {}
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingValueSource;
+
+/**
+ * Utilities used by service binding manager components.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class Util
+{
+
+ public static InputStream getInputStream(URL url) throws IOException
+ {
+ URLConnection conn = url.openConnection();
+ conn.connect();
+ return conn.getInputStream();
+ }
+
+ public static InputStream getInputStream(String resource) throws IOException
+ {
+ try
+ {
+ URL url = new URL(resource);
+ return getInputStream(url);
+ }
+ catch (MalformedURLException mue)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return cl.getResourceAsStream(resource);
+ }
+ }
+
+ public static InputStreamReader getInputStreamReader(URL url) throws IOException
+ {
+ return new InputStreamReader(getInputStream(url));
+ }
+
+ public static InputStreamReader getInputStreamReader(String resource) throws IOException
+ {
+ try
+ {
+ URL url = new URL(resource);
+ return getInputStreamReader(url);
+ }
+ catch (MalformedURLException mue)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = cl.getResourceAsStream(resource);
+ if (is == null)
+ throw new IllegalArgumentException("No resource " + resource + " found");
+ return new InputStreamReader(is);
+ }
+ }
+
+ public static String getContentAsString(URL url) throws IOException
+ {
+ InputStreamReader isr = getInputStreamReader(url);
+ return getContentAsString(isr);
+ }
+
+ public static String getContentAsString(String resource) throws IOException
+ {
+ InputStreamReader isr = getInputStreamReader(resource);
+ return getContentAsString(isr);
+ }
+
+ public static File writeToTempFile(String content) throws IOException
+ {
+ File targetFile = Util.createTempFile();
+ OutputStreamWriter osw = null;
+ try
+ {
+ osw = new OutputStreamWriter(new FileOutputStream(targetFile));
+ osw.write(content);
+
+ return targetFile;
+ }
+ finally
+ {
+ if (osw != null)
+ osw.close();
+ }
+ }
+
+ private static String getContentAsString(InputStreamReader isr) throws IOException
+ {
+ try
+ {
+ StringWriter writer = new StringWriter();
+ char[] buf = new char[1024];
+ int read;
+ while((read = isr.read(buf, 0, buf.length)) != -1)
+ {
+ writer.write(buf, 0, read);
+ }
+ return writer.toString();
+ }
+ finally
+ {
+ isr.close();
+ }
+ }
+
+ public static File createTempFile() throws IOException
+ {
+ String tmpName = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
+ File tempDirectory = new File(tmpName);
+ File targetFile = File.createTempFile("service-binding", ".tmp", tempDirectory);
+ targetFile.deleteOnExit();
+
+ return targetFile;
+ }
+
+ public static <T> T getBindingValue(ServiceBindingValueSource source, ServiceBinding binding, Class<T> expectedType) throws Exception
+ {
+ Object[] params = null;
+ Object obj = source.getServiceBindingValue(binding, params);
+ if (expectedType.isAssignableFrom(obj.getClass()))
+ {
+ return expectedType.cast(obj);
+ }
+ else
+ {
+ throw new IllegalStateException("Incompatible value source for " + binding + " -- must return " + expectedType.getSimpleName());
+ }
+ }
+
+ public static <T> T getBindingValueWithInput(ServiceBindingValueSource source, ServiceBinding binding, Object input, Class<T> expectedType) throws Exception
+ {
+ Object obj = source.getServiceBindingValue(binding, input);
+ if (expectedType.isAssignableFrom(obj.getClass()))
+ {
+ return expectedType.cast(obj);
+ }
+ else
+ {
+ throw new IllegalStateException("Incompatible value source for " + binding + " -- must return " + expectedType.getSimpleName());
+ }
+ }
+
+ /** Prevent instantiation */
+ private Util() {}
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/Util.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,66 +1,66 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Configuration object for a ServiceBindingValueSource that uses
- * XSL Transformation.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class XSLTServiceBindingValueSourceConfig
-{
- private final String xslt;
- private final HashMap<String, String> additionalAttributes = new HashMap<String, String>();
-
- public XSLTServiceBindingValueSourceConfig(String xslt)
- {
- this(xslt, null);
- }
-
- public XSLTServiceBindingValueSourceConfig(String xslt, Map<String, String> additionalAttributes)
- {
- if (xslt == null)
- throw new IllegalArgumentException("xslt is null");
- this.xslt = xslt;
-
- if (additionalAttributes != null)
- this.additionalAttributes.putAll(additionalAttributes);
- }
-
- public String getXslt()
- {
- return xslt;
- }
-
- public Map<String, String> getAdditionalAttributes()
- {
- return Collections.unmodifiableMap(additionalAttributes);
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Configuration object for a ServiceBindingValueSource that uses
+ * XSL Transformation.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class XSLTServiceBindingValueSourceConfig
+{
+ private final String xslt;
+ private final HashMap<String, String> additionalAttributes = new HashMap<String, String>();
+
+ public XSLTServiceBindingValueSourceConfig(String xslt)
+ {
+ this(xslt, null);
+ }
+
+ public XSLTServiceBindingValueSourceConfig(String xslt, Map<String, String> additionalAttributes)
+ {
+ if (xslt == null)
+ throw new IllegalArgumentException("xslt is null");
+ this.xslt = xslt;
+
+ if (additionalAttributes != null)
+ this.additionalAttributes.putAll(additionalAttributes);
+ }
+
+ public String getXslt()
+ {
+ return xslt;
+ }
+
+ public Map<String, String> getAdditionalAttributes()
+ {
+ return Collections.unmodifiableMap(additionalAttributes);
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,206 +1,206 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.services.binding.impl;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.net.URL;
-import java.util.Map;
-
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.jboss.services.binding.ElementServiceBindingValueSource;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.URLServiceBindingValueSource;
-import org.jboss.util.StringPropertyReplacer;
-import org.w3c.dom.Element;
-
-/**
- * A XSLTServiceBindingValueSourceImpl.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class XSLTServiceBindingValueSourceImpl implements URLServiceBindingValueSource, ElementServiceBindingValueSource
-{
-
- public String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception
- {
- if (input == null)
- throw new IllegalArgumentException("input cannot be null");
-
- XSLTServiceBindingValueSourceConfig config = getConfig(binding);
-
- Reader reader = null;
- Writer writer = null;
- try
- {
- reader = Util.getInputStreamReader(input);
-
- File targetFile = Util.createTempFile();
- writer = new OutputStreamWriter(new FileOutputStream(targetFile));
-
- doXslTransform(binding, config, reader, writer);
-
- return targetFile.getAbsolutePath();
- }
- finally
- {
- if (reader != null)
- reader.close();
- if (writer != null)
- writer.close();
- }
- }
-
- public URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception
- {
- if (input == null)
- throw new IllegalArgumentException("input cannot be null");
-
- XSLTServiceBindingValueSourceConfig config = getConfig(binding);
-
- Reader reader = null;
- Writer writer = null;
- try
- {
- reader = Util.getInputStreamReader(input);
-
- File targetFile = Util.createTempFile();
- writer = new OutputStreamWriter(new FileOutputStream(targetFile));
-
- doXslTransform(binding, config, reader, writer);
-
- return targetFile.toURL();
- }
- finally
- {
- if (reader != null)
- reader.close();
- if (writer != null)
- writer.close();
- }
- }
-
- public Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception
- {
- if (input == null)
- throw new IllegalArgumentException("input cannot be null");
-
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- if (editor == null)
- throw new IllegalStateException("Cannot find PropertyEditor for type Element");
-
- editor.setValue(input);
- Reader reader = new StringReader(editor.getAsText());
- Writer writer = new StringWriter();
-
- doXslTransform(binding, getConfig(binding), reader, writer);
-
- editor.setAsText(writer.toString());
- return (Element) editor.getValue();
- }
-
- public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
- {
- if (params == null || params.length != 1)
- {
- throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params'");
- }
-
- if (params[0] instanceof String)
- {
- return getResourceServiceBindingValue(binding, (String) params[0]);
- }
- else if (params[0] instanceof Element)
- {
- return getElementServiceBindingValue(binding, (Element) params[0]);
- }
- else if (params[0] instanceof URL)
- {
- return getURLServiceBindingValue(binding, (URL) params[0]);
- }
-
- throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params' of type String, Element or URL");
- }
-
- private XSLTServiceBindingValueSourceConfig getConfig(ServiceBinding binding)
- {
- Object config = binding.getServiceBindingValueSourceConfig();
- if (config instanceof XSLTServiceBindingValueSourceConfig)
- {
- return (XSLTServiceBindingValueSourceConfig) config;
- }
- else if (config == null)
- {
- throw new IllegalStateException("No config object bound to " + binding);
- }
- throw new IllegalStateException("Incompatible config object of type " +
- config.getClass() + " bound to " + binding +
- " -- must use " + XSLTServiceBindingValueSourceConfig.class.getName());
- }
-
- private void doXslTransform(ServiceBinding binding, XSLTServiceBindingValueSourceConfig config,
- Reader reader, Writer writer) throws TransformerException
- {
- Source xmlSource = new StreamSource(reader);
- Result xmlResult = new StreamResult(writer);
- Source xslSource = new StreamSource(new StringReader(config.getXslt()));
-
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer(xslSource);
-
- transformer.setParameter("port", new Integer(binding.getPort()));
- String host = binding.getHostName();
- if (host != null)
- {
- transformer.setParameter("host", host);
- }
-
- // Check for any arbitrary attributes
- Map<String, String> attributes = config.getAdditionalAttributes();
- for(Map.Entry<String, String> entry : attributes.entrySet())
- {
- String attrValue = StringPropertyReplacer.replaceProperties(entry.getValue());
- transformer.setParameter(entry.getKey(), attrValue);
- }
-
- transformer.transform(xmlSource, xmlResult);
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.services.binding.ElementServiceBindingValueSource;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.URLServiceBindingValueSource;
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Element;
+
+/**
+ * A XSLTServiceBindingValueSourceImpl.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class XSLTServiceBindingValueSourceImpl implements URLServiceBindingValueSource, ElementServiceBindingValueSource
+{
+
+ public String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception
+ {
+ if (input == null)
+ throw new IllegalArgumentException("input cannot be null");
+
+ XSLTServiceBindingValueSourceConfig config = getConfig(binding);
+
+ Reader reader = null;
+ Writer writer = null;
+ try
+ {
+ reader = Util.getInputStreamReader(input);
+
+ File targetFile = Util.createTempFile();
+ writer = new OutputStreamWriter(new FileOutputStream(targetFile));
+
+ doXslTransform(binding, config, reader, writer);
+
+ return targetFile.getAbsolutePath();
+ }
+ finally
+ {
+ if (reader != null)
+ reader.close();
+ if (writer != null)
+ writer.close();
+ }
+ }
+
+ public URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception
+ {
+ if (input == null)
+ throw new IllegalArgumentException("input cannot be null");
+
+ XSLTServiceBindingValueSourceConfig config = getConfig(binding);
+
+ Reader reader = null;
+ Writer writer = null;
+ try
+ {
+ reader = Util.getInputStreamReader(input);
+
+ File targetFile = Util.createTempFile();
+ writer = new OutputStreamWriter(new FileOutputStream(targetFile));
+
+ doXslTransform(binding, config, reader, writer);
+
+ return targetFile.toURL();
+ }
+ finally
+ {
+ if (reader != null)
+ reader.close();
+ if (writer != null)
+ writer.close();
+ }
+ }
+
+ public Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception
+ {
+ if (input == null)
+ throw new IllegalArgumentException("input cannot be null");
+
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ if (editor == null)
+ throw new IllegalStateException("Cannot find PropertyEditor for type Element");
+
+ editor.setValue(input);
+ Reader reader = new StringReader(editor.getAsText());
+ Writer writer = new StringWriter();
+
+ doXslTransform(binding, getConfig(binding), reader, writer);
+
+ editor.setAsText(writer.toString());
+ return (Element) editor.getValue();
+ }
+
+ public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+ {
+ if (params == null || params.length != 1)
+ {
+ throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params'");
+ }
+
+ if (params[0] instanceof String)
+ {
+ return getResourceServiceBindingValue(binding, (String) params[0]);
+ }
+ else if (params[0] instanceof Element)
+ {
+ return getElementServiceBindingValue(binding, (Element) params[0]);
+ }
+ else if (params[0] instanceof URL)
+ {
+ return getURLServiceBindingValue(binding, (URL) params[0]);
+ }
+
+ throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params' of type String, Element or URL");
+ }
+
+ private XSLTServiceBindingValueSourceConfig getConfig(ServiceBinding binding)
+ {
+ Object config = binding.getServiceBindingValueSourceConfig();
+ if (config instanceof XSLTServiceBindingValueSourceConfig)
+ {
+ return (XSLTServiceBindingValueSourceConfig) config;
+ }
+ else if (config == null)
+ {
+ throw new IllegalStateException("No config object bound to " + binding);
+ }
+ throw new IllegalStateException("Incompatible config object of type " +
+ config.getClass() + " bound to " + binding +
+ " -- must use " + XSLTServiceBindingValueSourceConfig.class.getName());
+ }
+
+ private void doXslTransform(ServiceBinding binding, XSLTServiceBindingValueSourceConfig config,
+ Reader reader, Writer writer) throws TransformerException
+ {
+ Source xmlSource = new StreamSource(reader);
+ Result xmlResult = new StreamResult(writer);
+ Source xslSource = new StreamSource(new StringReader(config.getXslt()));
+
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(xslSource);
+
+ transformer.setParameter("port", new Integer(binding.getPort()));
+ String host = binding.getHostName();
+ if (host != null)
+ {
+ transformer.setParameter("host", host);
+ }
+
+ // Check for any arbitrary attributes
+ Map<String, String> attributes = config.getAdditionalAttributes();
+ for(Map.Entry<String, String> entry : attributes.entrySet())
+ {
+ String attrValue = StringPropertyReplacer.replaceProperties(entry.getValue());
+ transformer.setParameter(entry.getKey(), attrValue);
+ }
+
+ transformer.transform(xmlSource, xmlResult);
+ }
+
+}
Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/deployment/BeanShellScriptClient.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/deployment/BeanShellScriptClient.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/deployment/BeanShellScriptClient.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,50 +1,50 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.deployment;
-
-import org.jboss.deployers.spi.DeploymentException;
-
-/**
- * Old client style bean shell client interface.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public interface BeanShellScriptClient
-{
- /**
- * Create bean shell script deployment.
- *
- * @param bshScript the script
- * @param scriptName the script name
- * @return deployment name
- * @throws DeploymentException for any error
- */
- String createScriptDeployment(String bshScript, String scriptName) throws DeploymentException;
-
- /**
- * Remove script deployment.
- *
- * @param scriptName the script name
- * @throws DeploymentException for any exception
- */
- void removeScriptDeployment(String scriptName) throws DeploymentException;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.deployment;
+
+import org.jboss.deployers.spi.DeploymentException;
+
+/**
+ * Old client style bean shell client interface.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface BeanShellScriptClient
+{
+ /**
+ * Create bean shell script deployment.
+ *
+ * @param bshScript the script
+ * @param scriptName the script name
+ * @return deployment name
+ * @throws DeploymentException for any error
+ */
+ String createScriptDeployment(String bshScript, String scriptName) throws DeploymentException;
+
+ /**
+ * Remove script deployment.
+ *
+ * @param scriptName the script name
+ * @throws DeploymentException for any exception
+ */
+ void removeScriptDeployment(String scriptName) throws DeploymentException;
+}
Property changes on: trunk/varia/src/main/org/jboss/varia/deployment/BeanShellScriptClient.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellDeployer.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellDeployer.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellDeployer.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,48 +1,48 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.deployment;
-
-import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * .bsh file deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class LegacyBeanShellDeployer extends AbstractVFSParsingDeployer<BeanShellScript>
-{
- public LegacyBeanShellDeployer()
- {
- super(BeanShellScript.class);
- setSuffix(".bsh");
- }
-
- protected BeanShellScript parse(VFSDeploymentUnit vfsDeploymentUnit, VirtualFile virtualFile, BeanShellScript root) throws Exception
- {
- if (log.isTraceEnabled())
- log.trace("Parsing bean shell file to create script instance: " + virtualFile);
-
- return new BeanShellScript(virtualFile.toURL());
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.deployment;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * .bsh file deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LegacyBeanShellDeployer extends AbstractVFSParsingDeployer<BeanShellScript>
+{
+ public LegacyBeanShellDeployer()
+ {
+ super(BeanShellScript.class);
+ setSuffix(".bsh");
+ }
+
+ protected BeanShellScript parse(VFSDeploymentUnit vfsDeploymentUnit, VirtualFile virtualFile, BeanShellScript root) throws Exception
+ {
+ if (log.isTraceEnabled())
+ log.trace("Parsing bean shell file to create script instance: " + virtualFile);
+
+ return new BeanShellScript(virtualFile.toURL());
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptClient.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptClient.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptClient.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,100 +1,100 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.deployment;
-
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.managed.api.annotation.ManagementOperation;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.logging.Logger;
-
-/**
- * Old client style bean shell invocation client.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
- at ManagementObject
-public class LegacyBeanShellScriptClient implements BeanShellScriptClient
-{
- protected Logger log = Logger.getLogger(getClass());
- private DeployerClient deployer;
-
- public LegacyBeanShellScriptClient(DeployerClient deployer)
- {
- if (deployer == null)
- throw new IllegalArgumentException("Null client deployer.");
- this.deployer = deployer;
- }
-
- protected BeanShellScript createBeanShellScript(String bshScript, String scriptName)
- throws org.jboss.deployment.DeploymentException
- {
- InputStream stream = new ByteArrayInputStream(bshScript.getBytes());
- try
- {
- return new BeanShellScript(this + ": " + scriptName, stream);
- }
- finally
- {
- try
- {
- stream.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
-
- @ManagementOperation
- public String createScriptDeployment(String bshScript, String scriptName) throws DeploymentException
- {
- if (bshScript == null)
- throw new IllegalArgumentException("Null bean shell script.");
-
- if (scriptName == null)
- throw new IllegalArgumentException("Null script name.");
-
- BeanShellScript script = createBeanShellScript(bshScript, scriptName);
- Deployment deployment = new AbstractDeployment(scriptName);
- MutableAttachments mutableAttachments = ((MutableAttachments)deployment.getPredeterminedManagedObjects());
- mutableAttachments.addAttachment(BeanShellScript.class, script);
-
- deployer.addDeployment(deployment);
- deployer.process();
-
- return deployment.getName();
- }
-
- @ManagementOperation
- public void removeScriptDeployment(String scriptName) throws DeploymentException
- {
- deployer.removeDeployment(scriptName);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.deployment;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.logging.Logger;
+
+/**
+ * Old client style bean shell invocation client.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at ManagementObject
+public class LegacyBeanShellScriptClient implements BeanShellScriptClient
+{
+ protected Logger log = Logger.getLogger(getClass());
+ private DeployerClient deployer;
+
+ public LegacyBeanShellScriptClient(DeployerClient deployer)
+ {
+ if (deployer == null)
+ throw new IllegalArgumentException("Null client deployer.");
+ this.deployer = deployer;
+ }
+
+ protected BeanShellScript createBeanShellScript(String bshScript, String scriptName)
+ throws org.jboss.deployment.DeploymentException
+ {
+ InputStream stream = new ByteArrayInputStream(bshScript.getBytes());
+ try
+ {
+ return new BeanShellScript(this + ": " + scriptName, stream);
+ }
+ finally
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+
+ @ManagementOperation
+ public String createScriptDeployment(String bshScript, String scriptName) throws DeploymentException
+ {
+ if (bshScript == null)
+ throw new IllegalArgumentException("Null bean shell script.");
+
+ if (scriptName == null)
+ throw new IllegalArgumentException("Null script name.");
+
+ BeanShellScript script = createBeanShellScript(bshScript, scriptName);
+ Deployment deployment = new AbstractDeployment(scriptName);
+ MutableAttachments mutableAttachments = ((MutableAttachments)deployment.getPredeterminedManagedObjects());
+ mutableAttachments.addAttachment(BeanShellScript.class, script);
+
+ deployer.addDeployment(deployment);
+ deployer.process();
+
+ return deployment.getName();
+ }
+
+ @ManagementOperation
+ public void removeScriptDeployment(String scriptName) throws DeploymentException
+ {
+ deployer.removeDeployment(scriptName);
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptClient.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptDeployer.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptDeployer.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptDeployer.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,147 +1,147 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.deployment;
-
-import java.util.Arrays;
-import java.util.Collection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.ControllerMode;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.mx.util.ObjectNameConverter;
-import org.jboss.system.ServiceController;
-import org.jboss.system.microcontainer.LifecycleDependencyItem;
-import org.jboss.system.microcontainer.ServiceControllerContext;
-
-/**
- * Old mbean style bean shell script deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class LegacyBeanShellScriptDeployer extends AbstractSimpleRealDeployer<BeanShellScript>
-{
- public static final String BASE_SCRIPT_OBJECT_NAME = "jboss.scripts:type=BeanShell";
- /** The service controller */
- private ServiceController serviceController;
- /** The default controller mode */
- private ControllerMode mode = ControllerMode.AUTOMATIC;
-
- public LegacyBeanShellScriptDeployer(ServiceController serviceController)
- {
- super(BeanShellScript.class);
- if (serviceController == null)
- throw new IllegalArgumentException("Null service controller.");
- this.serviceController = serviceController;
- }
-
- /**
- * Get the bean shell script name.
- *
- * @param script the script
- * @param deploymentUnit the deployment unit
- * @return get script's object name
- * @throws MalformedObjectNameException for any error
- */
- protected ObjectName getBshScriptName(BeanShellScript script, DeploymentUnit deploymentUnit)
- throws MalformedObjectNameException
- {
- ObjectName bshScriptName = script.getPreferedObjectName();
- if (bshScriptName == null)
- {
- bshScriptName = ObjectNameConverter.convert(BASE_SCRIPT_OBJECT_NAME + ",url=" + deploymentUnit.getSimpleName());
- }
- return bshScriptName;
- }
-
- public void deploy(DeploymentUnit deploymentUnit, BeanShellScript script) throws DeploymentException
- {
- try
- {
- Controller controller = serviceController.getKernel().getController();
- ObjectName bshScriptName = getBshScriptName(script, deploymentUnit);
- ServiceControllerContext context = new ServiceControllerContext(serviceController, bshScriptName, script);
- context.setMode(mode);
- ObjectName[] depends = script.getDependsServices();
- if (depends != null)
- addDependencies(context, Arrays.asList(depends));
-
- if (log.isTraceEnabled())
- log.trace("Installing bean shell script: " + bshScriptName);
-
- controller.install(context);
- }
- catch (Throwable t)
- {
- throw DeploymentException.rethrowAsDeploymentException("Unable to deploy bean shell script.", t);
- }
- }
-
- public void undeploy(DeploymentUnit deploymentUnit, BeanShellScript script)
- {
- try
- {
- ObjectName bshScriptName = getBshScriptName(script, deploymentUnit);
- Controller controller = serviceController.getKernel().getController();
-
- if (log.isTraceEnabled())
- log.trace("Uninstalling bean shell script: " + bshScriptName);
-
- controller.uninstall(bshScriptName.getCanonicalName());
- }
- catch (Throwable t)
- {
- log.error("Exception while undeploying bean shell script: " + t);
- }
- }
-
- /**
- * Add the passed lifecycle dependencies to the context
- *
- * @param context the context
- * @param depends the dependencies
- */
- private void addDependencies(ServiceControllerContext context, Collection<ObjectName> depends)
- {
- DependencyInfo info = context.getDependencyInfo();
- for (ObjectName other : depends)
- {
- info.addIDependOn(new LifecycleDependencyItem(context.getName(), other.getCanonicalName(), ControllerState.CREATE));
- info.addIDependOn(new LifecycleDependencyItem(context.getName(), other.getCanonicalName(), ControllerState.START));
- }
- }
-
- /**
- * Set the mode.
- *
- * @param mode the controller mode
- */
- public void setMode(String mode)
- {
- this.mode = ControllerMode.getInstance(mode);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.deployment;
+
+import java.util.Arrays;
+import java.util.Collection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.mx.util.ObjectNameConverter;
+import org.jboss.system.ServiceController;
+import org.jboss.system.microcontainer.LifecycleDependencyItem;
+import org.jboss.system.microcontainer.ServiceControllerContext;
+
+/**
+ * Old mbean style bean shell script deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LegacyBeanShellScriptDeployer extends AbstractSimpleRealDeployer<BeanShellScript>
+{
+ public static final String BASE_SCRIPT_OBJECT_NAME = "jboss.scripts:type=BeanShell";
+ /** The service controller */
+ private ServiceController serviceController;
+ /** The default controller mode */
+ private ControllerMode mode = ControllerMode.AUTOMATIC;
+
+ public LegacyBeanShellScriptDeployer(ServiceController serviceController)
+ {
+ super(BeanShellScript.class);
+ if (serviceController == null)
+ throw new IllegalArgumentException("Null service controller.");
+ this.serviceController = serviceController;
+ }
+
+ /**
+ * Get the bean shell script name.
+ *
+ * @param script the script
+ * @param deploymentUnit the deployment unit
+ * @return get script's object name
+ * @throws MalformedObjectNameException for any error
+ */
+ protected ObjectName getBshScriptName(BeanShellScript script, DeploymentUnit deploymentUnit)
+ throws MalformedObjectNameException
+ {
+ ObjectName bshScriptName = script.getPreferedObjectName();
+ if (bshScriptName == null)
+ {
+ bshScriptName = ObjectNameConverter.convert(BASE_SCRIPT_OBJECT_NAME + ",url=" + deploymentUnit.getSimpleName());
+ }
+ return bshScriptName;
+ }
+
+ public void deploy(DeploymentUnit deploymentUnit, BeanShellScript script) throws DeploymentException
+ {
+ try
+ {
+ Controller controller = serviceController.getKernel().getController();
+ ObjectName bshScriptName = getBshScriptName(script, deploymentUnit);
+ ServiceControllerContext context = new ServiceControllerContext(serviceController, bshScriptName, script);
+ context.setMode(mode);
+ ObjectName[] depends = script.getDependsServices();
+ if (depends != null)
+ addDependencies(context, Arrays.asList(depends));
+
+ if (log.isTraceEnabled())
+ log.trace("Installing bean shell script: " + bshScriptName);
+
+ controller.install(context);
+ }
+ catch (Throwable t)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Unable to deploy bean shell script.", t);
+ }
+ }
+
+ public void undeploy(DeploymentUnit deploymentUnit, BeanShellScript script)
+ {
+ try
+ {
+ ObjectName bshScriptName = getBshScriptName(script, deploymentUnit);
+ Controller controller = serviceController.getKernel().getController();
+
+ if (log.isTraceEnabled())
+ log.trace("Uninstalling bean shell script: " + bshScriptName);
+
+ controller.uninstall(bshScriptName.getCanonicalName());
+ }
+ catch (Throwable t)
+ {
+ log.error("Exception while undeploying bean shell script: " + t);
+ }
+ }
+
+ /**
+ * Add the passed lifecycle dependencies to the context
+ *
+ * @param context the context
+ * @param depends the dependencies
+ */
+ private void addDependencies(ServiceControllerContext context, Collection<ObjectName> depends)
+ {
+ DependencyInfo info = context.getDependencyInfo();
+ for (ObjectName other : depends)
+ {
+ info.addIDependOn(new LifecycleDependencyItem(context.getName(), other.getCanonicalName(), ControllerState.CREATE));
+ info.addIDependOn(new LifecycleDependencyItem(context.getName(), other.getCanonicalName(), ControllerState.START));
+ }
+ }
+
+ /**
+ * Set the mode.
+ *
+ * @param mode the controller mode
+ */
+ public void setMode(String mode)
+ {
+ this.mode = ControllerMode.getInstance(mode);
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/varia/deployment/LegacyBeanShellScriptDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK5.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK5.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK5.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,733 +1,733 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.stats;
-
-import java.sql.SQLException;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLWarning;
-import java.sql.Statement;
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.ResultSetMetaData;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import java.sql.Savepoint;
-import java.sql.ParameterMetaData;
-
-import java.io.PrintWriter;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.Map;
-import java.util.Calendar;
-import java.math.BigDecimal;
-import java.net.URL;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision: 37459 $</tt>
- * @@jmx:mbean name="jboss.stats:name=DataSourceInterceptor"
- * extends="org.jboss.system.ServiceMBean"
- */
-public class DataSourceInterceptorJDK5 extends DataSourceInterceptor
-{
-
- public Connection getConnection() throws SQLException
- {
- return new ConnectionInterceptor(target.getConnection());
- }
-
- public Connection getConnection(String username, String password) throws SQLException
- {
- return new ConnectionInterceptor(target.getConnection());
- }
-
- // Inner
-
- public class ConnectionInterceptor
- implements Connection
- {
- private final Connection target;
-
- public ConnectionInterceptor(Connection target)
- {
- this.target = target;
- }
-
-
- public int getHoldability() throws SQLException
- {
- return target.getHoldability();
- }
-
-
- public int getTransactionIsolation() throws SQLException
- {
- return target.getTransactionIsolation();
- }
-
- public void clearWarnings() throws SQLException
- {
- target.clearWarnings();
- }
-
- public void close() throws SQLException
- {
- target.close();
- }
-
- public void commit() throws SQLException
- {
- target.commit();
- }
-
- public void rollback() throws SQLException
- {
- target.rollback();
- }
-
- public boolean getAutoCommit() throws SQLException
- {
- return target.getAutoCommit();
- }
-
- public boolean isClosed() throws SQLException
- {
- return target.isClosed();
- }
-
- public boolean isReadOnly() throws SQLException
- {
- return target.isReadOnly();
- }
-
-
- public void setHoldability(int holdability) throws SQLException
- {
- target.setHoldability(holdability);
- }
-
-
- public void setTransactionIsolation(int level) throws SQLException
- {
- target.setTransactionIsolation(level);
- }
-
- public void setAutoCommit(boolean autoCommit) throws SQLException
- {
- target.setAutoCommit(autoCommit);
- }
-
- public void setReadOnly(boolean readOnly) throws SQLException
- {
- target.setReadOnly(readOnly);
- }
-
- public String getCatalog() throws SQLException
- {
- return target.getCatalog();
- }
-
- public void setCatalog(String catalog) throws SQLException
- {
- target.setCatalog(catalog);
- }
-
- public DatabaseMetaData getMetaData() throws SQLException
- {
- return target.getMetaData();
- }
-
- public SQLWarning getWarnings() throws SQLException
- {
- return target.getWarnings();
- }
-
-
- public Savepoint setSavepoint() throws SQLException
- {
- return target.setSavepoint();
- }
-
-
-
- public void releaseSavepoint(Savepoint savepoint) throws SQLException
- {
- target.releaseSavepoint(savepoint);
- }
-
-
-
- public void rollback(Savepoint savepoint) throws SQLException
- {
- target.rollback(savepoint);
- }
-
-
- public Statement createStatement() throws SQLException
- {
- return new StatementInterceptor(this, target.createStatement());
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- {
- return new StatementInterceptor(this, target.createStatement(resultSetType, resultSetConcurrency));
- }
-
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
- {
- return new StatementInterceptor(this,
- target.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
- }
-
-
- public Map getTypeMap() throws SQLException
- {
- return target.getTypeMap();
- }
-
- public void setTypeMap(Map map) throws SQLException
- {
- target.setTypeMap(map);
- }
-
- public String nativeSQL(String sql) throws SQLException
- {
- return target.nativeSQL(sql);
- }
-
- public CallableStatement prepareCall(String sql) throws SQLException
- {
- return target.prepareCall(sql);
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException
- {
- return target.prepareCall(sql, resultSetType, resultSetConcurrency);
- }
-
-
- public CallableStatement prepareCall(String sql,
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException
- {
- return target.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
-
-
- public PreparedStatement prepareStatement(String sql) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql));
- }
-
-
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql, autoGeneratedKeys));
- }
-
-
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this,
- target.prepareStatement(sql, resultSetType, resultSetConcurrency));
- }
-
-
- public PreparedStatement prepareStatement(String sql,
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this,
- target.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
- }
-
-
-
- public PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnIndexes));
- }
-
-
-
- public Savepoint setSavepoint(String name) throws SQLException
- {
- return target.setSavepoint(name);
- }
-
-
-
- public PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnNames));
- }
-
- }
-
- public class StatementInterceptor
- implements Statement
- {
- private final Connection con;
- private final Statement target;
-
- public StatementInterceptor(Connection con, Statement target)
- {
- this.con = con;
- this.target = target;
- }
-
- public int getFetchDirection() throws SQLException
- {
- return target.getFetchDirection();
- }
-
- public int getFetchSize() throws SQLException
- {
- return target.getFetchSize();
- }
-
- public int getMaxFieldSize() throws SQLException
- {
- return target.getMaxFieldSize();
- }
-
- public int getMaxRows() throws SQLException
- {
- return target.getMaxRows();
- }
-
- public int getQueryTimeout() throws SQLException
- {
- return target.getQueryTimeout();
- }
-
- public int getResultSetConcurrency() throws SQLException
- {
- return target.getResultSetConcurrency();
- }
-
-
- public int getResultSetHoldability() throws SQLException
- {
- return target.getResultSetHoldability();
- }
-
-
- public int getResultSetType() throws SQLException
- {
- return target.getResultSetType();
- }
-
- public int getUpdateCount() throws SQLException
- {
- return target.getUpdateCount();
- }
-
- public void cancel() throws SQLException
- {
- target.cancel();
- }
-
- public void clearBatch() throws SQLException
- {
- target.clearBatch();
- }
-
- public void clearWarnings() throws SQLException
- {
- target.clearWarnings();
- }
-
- public void close() throws SQLException
- {
- target.close();
- }
-
- public boolean getMoreResults() throws SQLException
- {
- return target.getMoreResults();
- }
-
- public int[] executeBatch() throws SQLException
- {
- return target.executeBatch();
- }
-
- public void setFetchDirection(int direction) throws SQLException
- {
- target.setFetchDirection(direction);
- }
-
- public void setFetchSize(int rows) throws SQLException
- {
- target.setFetchSize(rows);
- }
-
- public void setMaxFieldSize(int max) throws SQLException
- {
- target.setMaxFieldSize(max);
- }
-
- public void setMaxRows(int max) throws SQLException
- {
- target.setMaxRows(max);
- }
-
- public void setQueryTimeout(int seconds) throws SQLException
- {
- target.setQueryTimeout(seconds);
- }
-
-
- public boolean getMoreResults(int current) throws SQLException
- {
- return target.getMoreResults(current);
- }
-
-
- public void setEscapeProcessing(boolean enable) throws SQLException
- {
- target.setEscapeProcessing(enable);
- }
-
- public int executeUpdate(String sql) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql);
- }
-
- public void addBatch(String sql) throws SQLException
- {
- logSql(sql);
- target.addBatch(sql);
- }
-
- public void setCursorName(String name) throws SQLException
- {
- target.setCursorName(name);
- }
-
- public boolean execute(String sql) throws SQLException
- {
- logSql(sql);
- return target.execute(sql);
- }
-
-
- public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql, autoGeneratedKeys);
- }
-
-
-
- public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
- {
- logSql(sql);
- return target.execute(sql, autoGeneratedKeys);
- }
-
-
-
- public int executeUpdate(String sql, int columnIndexes[]) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql, columnIndexes);
- }
-
-
-
- public boolean execute(String sql, int columnIndexes[]) throws SQLException
- {
- logSql(sql);
- return target.execute(sql, columnIndexes);
- }
-
-
- public Connection getConnection() throws SQLException
- {
- return con;
- }
-
-
- public ResultSet getGeneratedKeys() throws SQLException
- {
- return target.getGeneratedKeys();
- }
-
-
- public ResultSet getResultSet() throws SQLException
- {
- return target.getResultSet();
- }
-
- public SQLWarning getWarnings() throws SQLException
- {
- return target.getWarnings();
- }
-
-
- public int executeUpdate(String sql, String columnNames[]) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql, columnNames);
- }
-
-
-
- public boolean execute(String sql, String columnNames[]) throws SQLException
- {
- logSql(sql);
- return target.execute(sql, columnNames);
- }
-
-
- public ResultSet executeQuery(String sql) throws SQLException
- {
- logSql(sql);
- return target.executeQuery(sql);
- }
- }
-
- public class PreparedStatementInterceptor
- extends StatementInterceptor
- implements PreparedStatement
- {
- private final PreparedStatement target;
-
- public PreparedStatementInterceptor(Connection con, PreparedStatement target)
- {
- super(con, target);
- this.target = target;
- }
-
- public int executeUpdate() throws SQLException
- {
- return target.executeUpdate();
- }
-
- public void addBatch() throws SQLException
- {
- target.addBatch();
- }
-
- public void clearParameters() throws SQLException
- {
- target.clearParameters();
- }
-
- public boolean execute() throws SQLException
- {
- return target.execute();
- }
-
- public void setByte(int parameterIndex, byte x) throws SQLException
- {
- target.setByte(parameterIndex, x);
- }
-
- public void setDouble(int parameterIndex, double x) throws SQLException
- {
- target.setDouble(parameterIndex, x);
- }
-
- public void setFloat(int parameterIndex, float x) throws SQLException
- {
- target.setFloat(parameterIndex, x);
- }
-
- public void setInt(int parameterIndex, int x) throws SQLException
- {
- target.setInt(parameterIndex, x);
- }
-
- public void setNull(int parameterIndex, int sqlType) throws SQLException
- {
- target.setNull(parameterIndex, sqlType);
- }
-
- public void setLong(int parameterIndex, long x) throws SQLException
- {
- target.setLong(parameterIndex, x);
- }
-
- public void setShort(int parameterIndex, short x) throws SQLException
- {
- target.setShort(parameterIndex, x);
- }
-
- public void setBoolean(int parameterIndex, boolean x) throws SQLException
- {
- target.setBoolean(parameterIndex, x);
- }
-
- public void setBytes(int parameterIndex, byte x[]) throws SQLException
- {
- target.setBytes(parameterIndex, x);
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- target.setAsciiStream(parameterIndex, x, length);
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- target.setBinaryStream(parameterIndex, x, length);
- }
-
- public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- target.setUnicodeStream(parameterIndex, x, length);
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
- {
- target.setCharacterStream(parameterIndex, reader, length);
- }
-
- public void setObject(int parameterIndex, Object x) throws SQLException
- {
- target.setObject(parameterIndex, x);
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
- {
- target.setObject(parameterIndex, x, targetSqlType);
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
- {
- target.setObject(parameterIndex, x, targetSqlType, scale);
- }
-
- public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException
- {
- target.setNull(paramIndex, sqlType, typeName);
- }
-
- public void setString(int parameterIndex, String x) throws SQLException
- {
- target.setString(parameterIndex, x);
- }
-
- public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
- {
- target.setBigDecimal(parameterIndex, x);
- }
-
-
- public void setURL(int parameterIndex, URL x) throws SQLException
- {
- target.setURL(parameterIndex, x);
- }
-
-
- public void setArray(int i, Array x) throws SQLException
- {
- target.setArray(i, x);
- }
-
- public void setBlob(int i, Blob x) throws SQLException
- {
- target.setBlob(i, x);
- }
-
- public void setClob(int i, Clob x) throws SQLException
- {
- target.setClob(i, x);
- }
-
- public void setDate(int parameterIndex, Date x) throws SQLException
- {
- target.setDate(parameterIndex, x);
- }
-
-
- public ParameterMetaData getParameterMetaData() throws SQLException
- {
- return target.getParameterMetaData();
- }
-
-
- public void setRef(int i, Ref x) throws SQLException
- {
- target.setRef(i, x);
- }
-
- public ResultSet executeQuery() throws SQLException
- {
- return target.executeQuery();
- }
-
- public ResultSetMetaData getMetaData() throws SQLException
- {
- return target.getMetaData();
- }
-
- public void setTime(int parameterIndex, Time x) throws SQLException
- {
- target.setTime(parameterIndex, x);
- }
-
- public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
- {
- target.setTimestamp(parameterIndex, x);
- }
-
- public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
- {
- target.setDate(parameterIndex, x, cal);
- }
-
- public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
- {
- target.setTime(parameterIndex, x, cal);
- }
-
- public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
- {
- target.setTimestamp(parameterIndex, x, cal);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.stats;
+
+import java.sql.SQLException;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.ResultSetMetaData;
+import java.sql.Time;
+import java.sql.Timestamp;
+
+import java.sql.Savepoint;
+import java.sql.ParameterMetaData;
+
+import java.io.PrintWriter;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Map;
+import java.util.Calendar;
+import java.math.BigDecimal;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37459 $</tt>
+ * @@jmx:mbean name="jboss.stats:name=DataSourceInterceptor"
+ * extends="org.jboss.system.ServiceMBean"
+ */
+public class DataSourceInterceptorJDK5 extends DataSourceInterceptor
+{
+
+ public Connection getConnection() throws SQLException
+ {
+ return new ConnectionInterceptor(target.getConnection());
+ }
+
+ public Connection getConnection(String username, String password) throws SQLException
+ {
+ return new ConnectionInterceptor(target.getConnection());
+ }
+
+ // Inner
+
+ public class ConnectionInterceptor
+ implements Connection
+ {
+ private final Connection target;
+
+ public ConnectionInterceptor(Connection target)
+ {
+ this.target = target;
+ }
+
+
+ public int getHoldability() throws SQLException
+ {
+ return target.getHoldability();
+ }
+
+
+ public int getTransactionIsolation() throws SQLException
+ {
+ return target.getTransactionIsolation();
+ }
+
+ public void clearWarnings() throws SQLException
+ {
+ target.clearWarnings();
+ }
+
+ public void close() throws SQLException
+ {
+ target.close();
+ }
+
+ public void commit() throws SQLException
+ {
+ target.commit();
+ }
+
+ public void rollback() throws SQLException
+ {
+ target.rollback();
+ }
+
+ public boolean getAutoCommit() throws SQLException
+ {
+ return target.getAutoCommit();
+ }
+
+ public boolean isClosed() throws SQLException
+ {
+ return target.isClosed();
+ }
+
+ public boolean isReadOnly() throws SQLException
+ {
+ return target.isReadOnly();
+ }
+
+
+ public void setHoldability(int holdability) throws SQLException
+ {
+ target.setHoldability(holdability);
+ }
+
+
+ public void setTransactionIsolation(int level) throws SQLException
+ {
+ target.setTransactionIsolation(level);
+ }
+
+ public void setAutoCommit(boolean autoCommit) throws SQLException
+ {
+ target.setAutoCommit(autoCommit);
+ }
+
+ public void setReadOnly(boolean readOnly) throws SQLException
+ {
+ target.setReadOnly(readOnly);
+ }
+
+ public String getCatalog() throws SQLException
+ {
+ return target.getCatalog();
+ }
+
+ public void setCatalog(String catalog) throws SQLException
+ {
+ target.setCatalog(catalog);
+ }
+
+ public DatabaseMetaData getMetaData() throws SQLException
+ {
+ return target.getMetaData();
+ }
+
+ public SQLWarning getWarnings() throws SQLException
+ {
+ return target.getWarnings();
+ }
+
+
+ public Savepoint setSavepoint() throws SQLException
+ {
+ return target.setSavepoint();
+ }
+
+
+
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException
+ {
+ target.releaseSavepoint(savepoint);
+ }
+
+
+
+ public void rollback(Savepoint savepoint) throws SQLException
+ {
+ target.rollback(savepoint);
+ }
+
+
+ public Statement createStatement() throws SQLException
+ {
+ return new StatementInterceptor(this, target.createStatement());
+ }
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+ return new StatementInterceptor(this, target.createStatement(resultSetType, resultSetConcurrency));
+ }
+
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException
+ {
+ return new StatementInterceptor(this,
+ target.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
+ }
+
+
+ public Map getTypeMap() throws SQLException
+ {
+ return target.getTypeMap();
+ }
+
+ public void setTypeMap(Map map) throws SQLException
+ {
+ target.setTypeMap(map);
+ }
+
+ public String nativeSQL(String sql) throws SQLException
+ {
+ return target.nativeSQL(sql);
+ }
+
+ public CallableStatement prepareCall(String sql) throws SQLException
+ {
+ return target.prepareCall(sql);
+ }
+
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+ return target.prepareCall(sql, resultSetType, resultSetConcurrency);
+ }
+
+
+ public CallableStatement prepareCall(String sql,
+ int resultSetType,
+ int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ return target.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+
+ public PreparedStatement prepareStatement(String sql) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql));
+ }
+
+
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql, autoGeneratedKeys));
+ }
+
+
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this,
+ target.prepareStatement(sql, resultSetType, resultSetConcurrency));
+ }
+
+
+ public PreparedStatement prepareStatement(String sql,
+ int resultSetType,
+ int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this,
+ target.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
+ }
+
+
+
+ public PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnIndexes));
+ }
+
+
+
+ public Savepoint setSavepoint(String name) throws SQLException
+ {
+ return target.setSavepoint(name);
+ }
+
+
+
+ public PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnNames));
+ }
+
+ }
+
+ public class StatementInterceptor
+ implements Statement
+ {
+ private final Connection con;
+ private final Statement target;
+
+ public StatementInterceptor(Connection con, Statement target)
+ {
+ this.con = con;
+ this.target = target;
+ }
+
+ public int getFetchDirection() throws SQLException
+ {
+ return target.getFetchDirection();
+ }
+
+ public int getFetchSize() throws SQLException
+ {
+ return target.getFetchSize();
+ }
+
+ public int getMaxFieldSize() throws SQLException
+ {
+ return target.getMaxFieldSize();
+ }
+
+ public int getMaxRows() throws SQLException
+ {
+ return target.getMaxRows();
+ }
+
+ public int getQueryTimeout() throws SQLException
+ {
+ return target.getQueryTimeout();
+ }
+
+ public int getResultSetConcurrency() throws SQLException
+ {
+ return target.getResultSetConcurrency();
+ }
+
+
+ public int getResultSetHoldability() throws SQLException
+ {
+ return target.getResultSetHoldability();
+ }
+
+
+ public int getResultSetType() throws SQLException
+ {
+ return target.getResultSetType();
+ }
+
+ public int getUpdateCount() throws SQLException
+ {
+ return target.getUpdateCount();
+ }
+
+ public void cancel() throws SQLException
+ {
+ target.cancel();
+ }
+
+ public void clearBatch() throws SQLException
+ {
+ target.clearBatch();
+ }
+
+ public void clearWarnings() throws SQLException
+ {
+ target.clearWarnings();
+ }
+
+ public void close() throws SQLException
+ {
+ target.close();
+ }
+
+ public boolean getMoreResults() throws SQLException
+ {
+ return target.getMoreResults();
+ }
+
+ public int[] executeBatch() throws SQLException
+ {
+ return target.executeBatch();
+ }
+
+ public void setFetchDirection(int direction) throws SQLException
+ {
+ target.setFetchDirection(direction);
+ }
+
+ public void setFetchSize(int rows) throws SQLException
+ {
+ target.setFetchSize(rows);
+ }
+
+ public void setMaxFieldSize(int max) throws SQLException
+ {
+ target.setMaxFieldSize(max);
+ }
+
+ public void setMaxRows(int max) throws SQLException
+ {
+ target.setMaxRows(max);
+ }
+
+ public void setQueryTimeout(int seconds) throws SQLException
+ {
+ target.setQueryTimeout(seconds);
+ }
+
+
+ public boolean getMoreResults(int current) throws SQLException
+ {
+ return target.getMoreResults(current);
+ }
+
+
+ public void setEscapeProcessing(boolean enable) throws SQLException
+ {
+ target.setEscapeProcessing(enable);
+ }
+
+ public int executeUpdate(String sql) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql);
+ }
+
+ public void addBatch(String sql) throws SQLException
+ {
+ logSql(sql);
+ target.addBatch(sql);
+ }
+
+ public void setCursorName(String name) throws SQLException
+ {
+ target.setCursorName(name);
+ }
+
+ public boolean execute(String sql) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql);
+ }
+
+
+ public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql, autoGeneratedKeys);
+ }
+
+
+
+ public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql, autoGeneratedKeys);
+ }
+
+
+
+ public int executeUpdate(String sql, int columnIndexes[]) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql, columnIndexes);
+ }
+
+
+
+ public boolean execute(String sql, int columnIndexes[]) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql, columnIndexes);
+ }
+
+
+ public Connection getConnection() throws SQLException
+ {
+ return con;
+ }
+
+
+ public ResultSet getGeneratedKeys() throws SQLException
+ {
+ return target.getGeneratedKeys();
+ }
+
+
+ public ResultSet getResultSet() throws SQLException
+ {
+ return target.getResultSet();
+ }
+
+ public SQLWarning getWarnings() throws SQLException
+ {
+ return target.getWarnings();
+ }
+
+
+ public int executeUpdate(String sql, String columnNames[]) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql, columnNames);
+ }
+
+
+
+ public boolean execute(String sql, String columnNames[]) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql, columnNames);
+ }
+
+
+ public ResultSet executeQuery(String sql) throws SQLException
+ {
+ logSql(sql);
+ return target.executeQuery(sql);
+ }
+ }
+
+ public class PreparedStatementInterceptor
+ extends StatementInterceptor
+ implements PreparedStatement
+ {
+ private final PreparedStatement target;
+
+ public PreparedStatementInterceptor(Connection con, PreparedStatement target)
+ {
+ super(con, target);
+ this.target = target;
+ }
+
+ public int executeUpdate() throws SQLException
+ {
+ return target.executeUpdate();
+ }
+
+ public void addBatch() throws SQLException
+ {
+ target.addBatch();
+ }
+
+ public void clearParameters() throws SQLException
+ {
+ target.clearParameters();
+ }
+
+ public boolean execute() throws SQLException
+ {
+ return target.execute();
+ }
+
+ public void setByte(int parameterIndex, byte x) throws SQLException
+ {
+ target.setByte(parameterIndex, x);
+ }
+
+ public void setDouble(int parameterIndex, double x) throws SQLException
+ {
+ target.setDouble(parameterIndex, x);
+ }
+
+ public void setFloat(int parameterIndex, float x) throws SQLException
+ {
+ target.setFloat(parameterIndex, x);
+ }
+
+ public void setInt(int parameterIndex, int x) throws SQLException
+ {
+ target.setInt(parameterIndex, x);
+ }
+
+ public void setNull(int parameterIndex, int sqlType) throws SQLException
+ {
+ target.setNull(parameterIndex, sqlType);
+ }
+
+ public void setLong(int parameterIndex, long x) throws SQLException
+ {
+ target.setLong(parameterIndex, x);
+ }
+
+ public void setShort(int parameterIndex, short x) throws SQLException
+ {
+ target.setShort(parameterIndex, x);
+ }
+
+ public void setBoolean(int parameterIndex, boolean x) throws SQLException
+ {
+ target.setBoolean(parameterIndex, x);
+ }
+
+ public void setBytes(int parameterIndex, byte x[]) throws SQLException
+ {
+ target.setBytes(parameterIndex, x);
+ }
+
+ public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
+ {
+ target.setAsciiStream(parameterIndex, x, length);
+ }
+
+ public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
+ {
+ target.setBinaryStream(parameterIndex, x, length);
+ }
+
+ public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
+ {
+ target.setUnicodeStream(parameterIndex, x, length);
+ }
+
+ public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
+ {
+ target.setCharacterStream(parameterIndex, reader, length);
+ }
+
+ public void setObject(int parameterIndex, Object x) throws SQLException
+ {
+ target.setObject(parameterIndex, x);
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
+ {
+ target.setObject(parameterIndex, x, targetSqlType);
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
+ {
+ target.setObject(parameterIndex, x, targetSqlType, scale);
+ }
+
+ public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException
+ {
+ target.setNull(paramIndex, sqlType, typeName);
+ }
+
+ public void setString(int parameterIndex, String x) throws SQLException
+ {
+ target.setString(parameterIndex, x);
+ }
+
+ public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
+ {
+ target.setBigDecimal(parameterIndex, x);
+ }
+
+
+ public void setURL(int parameterIndex, URL x) throws SQLException
+ {
+ target.setURL(parameterIndex, x);
+ }
+
+
+ public void setArray(int i, Array x) throws SQLException
+ {
+ target.setArray(i, x);
+ }
+
+ public void setBlob(int i, Blob x) throws SQLException
+ {
+ target.setBlob(i, x);
+ }
+
+ public void setClob(int i, Clob x) throws SQLException
+ {
+ target.setClob(i, x);
+ }
+
+ public void setDate(int parameterIndex, Date x) throws SQLException
+ {
+ target.setDate(parameterIndex, x);
+ }
+
+
+ public ParameterMetaData getParameterMetaData() throws SQLException
+ {
+ return target.getParameterMetaData();
+ }
+
+
+ public void setRef(int i, Ref x) throws SQLException
+ {
+ target.setRef(i, x);
+ }
+
+ public ResultSet executeQuery() throws SQLException
+ {
+ return target.executeQuery();
+ }
+
+ public ResultSetMetaData getMetaData() throws SQLException
+ {
+ return target.getMetaData();
+ }
+
+ public void setTime(int parameterIndex, Time x) throws SQLException
+ {
+ target.setTime(parameterIndex, x);
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
+ {
+ target.setTimestamp(parameterIndex, x);
+ }
+
+ public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
+ {
+ target.setDate(parameterIndex, x, cal);
+ }
+
+ public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
+ {
+ target.setTime(parameterIndex, x, cal);
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
+ {
+ target.setTimestamp(parameterIndex, x, cal);
+ }
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK5.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK6.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK6.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK6.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,928 +1,928 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.stats;
-
-import java.sql.SQLException;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLWarning;
-import java.sql.Statement;
-import java.sql.CallableStatement;
-import java.sql.SQLClientInfoException;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.NClob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
-import java.sql.Struct;
-import java.sql.SQLXML;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import java.sql.Savepoint;
-import java.sql.ParameterMetaData;
-
-import java.io.PrintWriter;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.Map;
-import java.util.Calendar;
-import java.util.Properties;
-import java.math.BigDecimal;
-import java.net.URL;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision: 37459 $</tt>
- * @@jmx:mbean name="jboss.stats:name=DataSourceInterceptor"
- * extends="org.jboss.system.ServiceMBean"
- */
-public class DataSourceInterceptorJDK6 extends DataSourceInterceptor
-{
-
- public <T>T unwrap(Class<T> iface) throws SQLException
- {
- return target.unwrap(iface);
- }
-
- public boolean isWrapperFor(Class<?> iface) throws SQLException
- {
- return target.isWrapperFor(iface);
- }
-
- public Connection getConnection() throws SQLException
- {
- return new ConnectionInterceptor(target.getConnection());
- }
-
- public Connection getConnection(String username, String password) throws SQLException
- {
- return new ConnectionInterceptor(target.getConnection());
- }
-
- // Inner
-
- public class ConnectionInterceptor
- implements Connection
- {
- private final Connection target;
-
- public ConnectionInterceptor(Connection target)
- {
- this.target = target;
- }
-
-
- public int getHoldability() throws SQLException
- {
- return target.getHoldability();
- }
-
-
- public int getTransactionIsolation() throws SQLException
- {
- return target.getTransactionIsolation();
- }
-
- public void clearWarnings() throws SQLException
- {
- target.clearWarnings();
- }
-
- public void close() throws SQLException
- {
- target.close();
- }
-
- public void commit() throws SQLException
- {
- target.commit();
- }
-
- public void rollback() throws SQLException
- {
- target.rollback();
- }
-
- public boolean getAutoCommit() throws SQLException
- {
- return target.getAutoCommit();
- }
-
- public boolean isClosed() throws SQLException
- {
- return target.isClosed();
- }
-
- public boolean isReadOnly() throws SQLException
- {
- return target.isReadOnly();
- }
-
-
- public void setHoldability(int holdability) throws SQLException
- {
- target.setHoldability(holdability);
- }
-
-
- public void setTransactionIsolation(int level) throws SQLException
- {
- target.setTransactionIsolation(level);
- }
-
- public void setAutoCommit(boolean autoCommit) throws SQLException
- {
- target.setAutoCommit(autoCommit);
- }
-
- public void setReadOnly(boolean readOnly) throws SQLException
- {
- target.setReadOnly(readOnly);
- }
-
- public String getCatalog() throws SQLException
- {
- return target.getCatalog();
- }
-
- public void setCatalog(String catalog) throws SQLException
- {
- target.setCatalog(catalog);
- }
-
- public DatabaseMetaData getMetaData() throws SQLException
- {
- return target.getMetaData();
- }
-
- public SQLWarning getWarnings() throws SQLException
- {
- return target.getWarnings();
- }
-
-
- public Savepoint setSavepoint() throws SQLException
- {
- return target.setSavepoint();
- }
-
-
-
- public void releaseSavepoint(Savepoint savepoint) throws SQLException
- {
- target.releaseSavepoint(savepoint);
- }
-
-
-
- public void rollback(Savepoint savepoint) throws SQLException
- {
- target.rollback(savepoint);
- }
-
-
- public Statement createStatement() throws SQLException
- {
- return new StatementInterceptor(this, target.createStatement());
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- {
- return new StatementInterceptor(this, target.createStatement(resultSetType, resultSetConcurrency));
- }
-
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
- {
- return new StatementInterceptor(this,
- target.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
- }
-
-
- public Map getTypeMap() throws SQLException
- {
- return target.getTypeMap();
- }
-
- public void setTypeMap(Map map) throws SQLException
- {
- target.setTypeMap(map);
- }
-
- public String nativeSQL(String sql) throws SQLException
- {
- return target.nativeSQL(sql);
- }
-
- public CallableStatement prepareCall(String sql) throws SQLException
- {
- return target.prepareCall(sql);
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException
- {
- return target.prepareCall(sql, resultSetType, resultSetConcurrency);
- }
-
-
- public CallableStatement prepareCall(String sql,
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException
- {
- return target.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
-
-
- public PreparedStatement prepareStatement(String sql) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql));
- }
-
-
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql, autoGeneratedKeys));
- }
-
-
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this,
- target.prepareStatement(sql, resultSetType, resultSetConcurrency));
- }
-
-
- public PreparedStatement prepareStatement(String sql,
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this,
- target.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
- }
-
-
-
- public PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnIndexes));
- }
-
-
-
- public Savepoint setSavepoint(String name) throws SQLException
- {
- return target.setSavepoint(name);
- }
-
-
-
- public PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException
- {
- logSql(sql);
- return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnNames));
- }
-
- public <T>T unwrap(Class<T> iface) throws SQLException
- {
- return target.unwrap(iface);
- }
-
- public boolean isWrapperFor(Class<?> iface) throws SQLException
- {
- return target.isWrapperFor(iface);
- }
-
- public Clob createClob() throws SQLException
- {
- return target.createClob();
- }
-
- public Blob createBlob() throws SQLException
- {
- return target.createBlob();
- }
-
- public NClob createNClob() throws SQLException
- {
- return target.createNClob();
- }
-
- public SQLXML createSQLXML() throws SQLException
- {
- return target.createSQLXML();
- }
-
- public boolean isValid(int timeout) throws SQLException
- {
- return target.isValid(timeout);
- }
-
- public void setClientInfo(String name, String value) throws SQLClientInfoException
- {
- target.setClientInfo(name, value);
- }
-
- public void setClientInfo(Properties properties) throws SQLClientInfoException
- {
- target.setClientInfo(properties);
- }
-
- public String getClientInfo(String name) throws SQLException
- {
- return target.getClientInfo(name);
- }
-
- public Properties getClientInfo() throws SQLException
- {
- return target.getClientInfo();
- }
-
- public Array createArrayOf(String typeName, Object[] elements) throws SQLException
- {
- return target.createArrayOf(typeName, elements);
- }
-
- public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- {
- return target.createStruct(typeName, attributes);
- }
- }
-
- public class StatementInterceptor
- implements Statement
- {
- private final Connection con;
- private final Statement target;
-
- public StatementInterceptor(Connection con, Statement target)
- {
- this.con = con;
- this.target = target;
- }
-
- public int getFetchDirection() throws SQLException
- {
- return target.getFetchDirection();
- }
-
- public int getFetchSize() throws SQLException
- {
- return target.getFetchSize();
- }
-
- public int getMaxFieldSize() throws SQLException
- {
- return target.getMaxFieldSize();
- }
-
- public int getMaxRows() throws SQLException
- {
- return target.getMaxRows();
- }
-
- public int getQueryTimeout() throws SQLException
- {
- return target.getQueryTimeout();
- }
-
- public int getResultSetConcurrency() throws SQLException
- {
- return target.getResultSetConcurrency();
- }
-
-
- public int getResultSetHoldability() throws SQLException
- {
- return target.getResultSetHoldability();
- }
-
-
- public int getResultSetType() throws SQLException
- {
- return target.getResultSetType();
- }
-
- public int getUpdateCount() throws SQLException
- {
- return target.getUpdateCount();
- }
-
- public void cancel() throws SQLException
- {
- target.cancel();
- }
-
- public void clearBatch() throws SQLException
- {
- target.clearBatch();
- }
-
- public void clearWarnings() throws SQLException
- {
- target.clearWarnings();
- }
-
- public void close() throws SQLException
- {
- target.close();
- }
-
- public boolean getMoreResults() throws SQLException
- {
- return target.getMoreResults();
- }
-
- public int[] executeBatch() throws SQLException
- {
- return target.executeBatch();
- }
-
- public void setFetchDirection(int direction) throws SQLException
- {
- target.setFetchDirection(direction);
- }
-
- public void setFetchSize(int rows) throws SQLException
- {
- target.setFetchSize(rows);
- }
-
- public void setMaxFieldSize(int max) throws SQLException
- {
- target.setMaxFieldSize(max);
- }
-
- public void setMaxRows(int max) throws SQLException
- {
- target.setMaxRows(max);
- }
-
- public void setQueryTimeout(int seconds) throws SQLException
- {
- target.setQueryTimeout(seconds);
- }
-
-
- public boolean getMoreResults(int current) throws SQLException
- {
- return target.getMoreResults(current);
- }
-
-
- public void setEscapeProcessing(boolean enable) throws SQLException
- {
- target.setEscapeProcessing(enable);
- }
-
- public int executeUpdate(String sql) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql);
- }
-
- public void addBatch(String sql) throws SQLException
- {
- logSql(sql);
- target.addBatch(sql);
- }
-
- public void setCursorName(String name) throws SQLException
- {
- target.setCursorName(name);
- }
-
- public boolean execute(String sql) throws SQLException
- {
- logSql(sql);
- return target.execute(sql);
- }
-
-
- public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql, autoGeneratedKeys);
- }
-
-
-
- public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
- {
- logSql(sql);
- return target.execute(sql, autoGeneratedKeys);
- }
-
-
-
- public int executeUpdate(String sql, int columnIndexes[]) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql, columnIndexes);
- }
-
-
-
- public boolean execute(String sql, int columnIndexes[]) throws SQLException
- {
- logSql(sql);
- return target.execute(sql, columnIndexes);
- }
-
-
- public Connection getConnection() throws SQLException
- {
- return con;
- }
-
-
- public ResultSet getGeneratedKeys() throws SQLException
- {
- return target.getGeneratedKeys();
- }
-
-
- public ResultSet getResultSet() throws SQLException
- {
- return target.getResultSet();
- }
-
- public SQLWarning getWarnings() throws SQLException
- {
- return target.getWarnings();
- }
-
-
- public int executeUpdate(String sql, String columnNames[]) throws SQLException
- {
- logSql(sql);
- return target.executeUpdate(sql, columnNames);
- }
-
-
-
- public boolean execute(String sql, String columnNames[]) throws SQLException
- {
- logSql(sql);
- return target.execute(sql, columnNames);
- }
-
-
- public ResultSet executeQuery(String sql) throws SQLException
- {
- logSql(sql);
- return target.executeQuery(sql);
- }
-
- public <T>T unwrap(Class<T> iface) throws SQLException
- {
- return target.unwrap(iface);
- }
-
- public boolean isWrapperFor(Class<?> iface) throws SQLException
- {
- return target.isWrapperFor(iface);
- }
-
- public boolean isClosed() throws SQLException
- {
- return target.isClosed();
- }
-
- public void setPoolable(boolean poolable) throws SQLException
- {
- target.setPoolable(poolable);
- }
-
- public boolean isPoolable() throws SQLException
- {
- return target.isPoolable();
- }
- }
-
- public class PreparedStatementInterceptor
- extends StatementInterceptor
- implements PreparedStatement
- {
- private final PreparedStatement target;
-
- public PreparedStatementInterceptor(Connection con, PreparedStatement target)
- {
- super(con, target);
- this.target = target;
- }
-
- public int executeUpdate() throws SQLException
- {
- return target.executeUpdate();
- }
-
- public void addBatch() throws SQLException
- {
- target.addBatch();
- }
-
- public void clearParameters() throws SQLException
- {
- target.clearParameters();
- }
-
- public boolean execute() throws SQLException
- {
- return target.execute();
- }
-
- public void setByte(int parameterIndex, byte x) throws SQLException
- {
- target.setByte(parameterIndex, x);
- }
-
- public void setDouble(int parameterIndex, double x) throws SQLException
- {
- target.setDouble(parameterIndex, x);
- }
-
- public void setFloat(int parameterIndex, float x) throws SQLException
- {
- target.setFloat(parameterIndex, x);
- }
-
- public void setInt(int parameterIndex, int x) throws SQLException
- {
- target.setInt(parameterIndex, x);
- }
-
- public void setNull(int parameterIndex, int sqlType) throws SQLException
- {
- target.setNull(parameterIndex, sqlType);
- }
-
- public void setLong(int parameterIndex, long x) throws SQLException
- {
- target.setLong(parameterIndex, x);
- }
-
- public void setShort(int parameterIndex, short x) throws SQLException
- {
- target.setShort(parameterIndex, x);
- }
-
- public void setBoolean(int parameterIndex, boolean x) throws SQLException
- {
- target.setBoolean(parameterIndex, x);
- }
-
- public void setBytes(int parameterIndex, byte x[]) throws SQLException
- {
- target.setBytes(parameterIndex, x);
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- target.setAsciiStream(parameterIndex, x, length);
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- target.setBinaryStream(parameterIndex, x, length);
- }
-
- public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- target.setUnicodeStream(parameterIndex, x, length);
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
- {
- target.setCharacterStream(parameterIndex, reader, length);
- }
-
- public void setObject(int parameterIndex, Object x) throws SQLException
- {
- target.setObject(parameterIndex, x);
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
- {
- target.setObject(parameterIndex, x, targetSqlType);
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
- {
- target.setObject(parameterIndex, x, targetSqlType, scale);
- }
-
- public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException
- {
- target.setNull(paramIndex, sqlType, typeName);
- }
-
- public void setString(int parameterIndex, String x) throws SQLException
- {
- target.setString(parameterIndex, x);
- }
-
- public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
- {
- target.setBigDecimal(parameterIndex, x);
- }
-
-
- public void setURL(int parameterIndex, URL x) throws SQLException
- {
- target.setURL(parameterIndex, x);
- }
-
-
- public void setArray(int i, Array x) throws SQLException
- {
- target.setArray(i, x);
- }
-
- public void setBlob(int i, Blob x) throws SQLException
- {
- target.setBlob(i, x);
- }
-
- public void setClob(int i, Clob x) throws SQLException
- {
- target.setClob(i, x);
- }
-
- public void setDate(int parameterIndex, Date x) throws SQLException
- {
- target.setDate(parameterIndex, x);
- }
-
-
- public ParameterMetaData getParameterMetaData() throws SQLException
- {
- return target.getParameterMetaData();
- }
-
-
- public void setRef(int i, Ref x) throws SQLException
- {
- target.setRef(i, x);
- }
-
- public ResultSet executeQuery() throws SQLException
- {
- return target.executeQuery();
- }
-
- public ResultSetMetaData getMetaData() throws SQLException
- {
- return target.getMetaData();
- }
-
- public void setTime(int parameterIndex, Time x) throws SQLException
- {
- target.setTime(parameterIndex, x);
- }
-
- public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
- {
- target.setTimestamp(parameterIndex, x);
- }
-
- public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
- {
- target.setDate(parameterIndex, x, cal);
- }
-
- public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
- {
- target.setTime(parameterIndex, x, cal);
- }
-
- public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
- {
- target.setTimestamp(parameterIndex, x, cal);
- }
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException
- {
- target.setRowId(parameterIndex, x);
- }
-
- public void setNString(int parameterIndex, String value) throws SQLException
- {
- target.setNString(parameterIndex, value);
- }
-
- public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
- {
- target.setNCharacterStream(parameterIndex, value, length);
- }
-
- public void setNClob(int parameterIndex, NClob value) throws SQLException
- {
- target.setNClob(parameterIndex, value);
- }
-
- public void setClob(int parameterIndex, Reader reader, long length) throws SQLException
- {
- target.setClob(parameterIndex, reader, length);
- }
-
- public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
- {
- target.setBlob(parameterIndex, inputStream, length);
- }
-
- public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
- {
- target.setNClob(parameterIndex, reader, length);
- }
-
- public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
- {
- target.setSQLXML(parameterIndex, xmlObject);
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
- {
- target.setAsciiStream(parameterIndex, x, length);
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
- {
- target.setBinaryStream(parameterIndex, x, length);
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
- {
- target.setCharacterStream(parameterIndex, reader, length);
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
- {
- target.setAsciiStream(parameterIndex, x);
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
- {
- target.setBinaryStream(parameterIndex, x);
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
- {
- target.setCharacterStream(parameterIndex, reader);
- }
-
- public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
- {
- target.setNCharacterStream(parameterIndex, value);
- }
-
- public void setClob(int parameterIndex, Reader reader) throws SQLException
- {
- target.setClob(parameterIndex, reader);
- }
-
- public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
- {
- target.setBlob(parameterIndex, inputStream);
- }
-
- public void setNClob(int parameterIndex, Reader reader) throws SQLException
- {
- target.setNClob(parameterIndex, reader);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.stats;
+
+import java.sql.SQLException;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.sql.CallableStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.NClob;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.Struct;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+
+import java.sql.Savepoint;
+import java.sql.ParameterMetaData;
+
+import java.io.PrintWriter;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Map;
+import java.util.Calendar;
+import java.util.Properties;
+import java.math.BigDecimal;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37459 $</tt>
+ * @@jmx:mbean name="jboss.stats:name=DataSourceInterceptor"
+ * extends="org.jboss.system.ServiceMBean"
+ */
+public class DataSourceInterceptorJDK6 extends DataSourceInterceptor
+{
+
+ public <T>T unwrap(Class<T> iface) throws SQLException
+ {
+ return target.unwrap(iface);
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+ return target.isWrapperFor(iface);
+ }
+
+ public Connection getConnection() throws SQLException
+ {
+ return new ConnectionInterceptor(target.getConnection());
+ }
+
+ public Connection getConnection(String username, String password) throws SQLException
+ {
+ return new ConnectionInterceptor(target.getConnection());
+ }
+
+ // Inner
+
+ public class ConnectionInterceptor
+ implements Connection
+ {
+ private final Connection target;
+
+ public ConnectionInterceptor(Connection target)
+ {
+ this.target = target;
+ }
+
+
+ public int getHoldability() throws SQLException
+ {
+ return target.getHoldability();
+ }
+
+
+ public int getTransactionIsolation() throws SQLException
+ {
+ return target.getTransactionIsolation();
+ }
+
+ public void clearWarnings() throws SQLException
+ {
+ target.clearWarnings();
+ }
+
+ public void close() throws SQLException
+ {
+ target.close();
+ }
+
+ public void commit() throws SQLException
+ {
+ target.commit();
+ }
+
+ public void rollback() throws SQLException
+ {
+ target.rollback();
+ }
+
+ public boolean getAutoCommit() throws SQLException
+ {
+ return target.getAutoCommit();
+ }
+
+ public boolean isClosed() throws SQLException
+ {
+ return target.isClosed();
+ }
+
+ public boolean isReadOnly() throws SQLException
+ {
+ return target.isReadOnly();
+ }
+
+
+ public void setHoldability(int holdability) throws SQLException
+ {
+ target.setHoldability(holdability);
+ }
+
+
+ public void setTransactionIsolation(int level) throws SQLException
+ {
+ target.setTransactionIsolation(level);
+ }
+
+ public void setAutoCommit(boolean autoCommit) throws SQLException
+ {
+ target.setAutoCommit(autoCommit);
+ }
+
+ public void setReadOnly(boolean readOnly) throws SQLException
+ {
+ target.setReadOnly(readOnly);
+ }
+
+ public String getCatalog() throws SQLException
+ {
+ return target.getCatalog();
+ }
+
+ public void setCatalog(String catalog) throws SQLException
+ {
+ target.setCatalog(catalog);
+ }
+
+ public DatabaseMetaData getMetaData() throws SQLException
+ {
+ return target.getMetaData();
+ }
+
+ public SQLWarning getWarnings() throws SQLException
+ {
+ return target.getWarnings();
+ }
+
+
+ public Savepoint setSavepoint() throws SQLException
+ {
+ return target.setSavepoint();
+ }
+
+
+
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException
+ {
+ target.releaseSavepoint(savepoint);
+ }
+
+
+
+ public void rollback(Savepoint savepoint) throws SQLException
+ {
+ target.rollback(savepoint);
+ }
+
+
+ public Statement createStatement() throws SQLException
+ {
+ return new StatementInterceptor(this, target.createStatement());
+ }
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+ return new StatementInterceptor(this, target.createStatement(resultSetType, resultSetConcurrency));
+ }
+
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException
+ {
+ return new StatementInterceptor(this,
+ target.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
+ }
+
+
+ public Map getTypeMap() throws SQLException
+ {
+ return target.getTypeMap();
+ }
+
+ public void setTypeMap(Map map) throws SQLException
+ {
+ target.setTypeMap(map);
+ }
+
+ public String nativeSQL(String sql) throws SQLException
+ {
+ return target.nativeSQL(sql);
+ }
+
+ public CallableStatement prepareCall(String sql) throws SQLException
+ {
+ return target.prepareCall(sql);
+ }
+
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+ return target.prepareCall(sql, resultSetType, resultSetConcurrency);
+ }
+
+
+ public CallableStatement prepareCall(String sql,
+ int resultSetType,
+ int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ return target.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+
+ public PreparedStatement prepareStatement(String sql) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql));
+ }
+
+
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql, autoGeneratedKeys));
+ }
+
+
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this,
+ target.prepareStatement(sql, resultSetType, resultSetConcurrency));
+ }
+
+
+ public PreparedStatement prepareStatement(String sql,
+ int resultSetType,
+ int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this,
+ target.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
+ }
+
+
+
+ public PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnIndexes));
+ }
+
+
+
+ public Savepoint setSavepoint(String name) throws SQLException
+ {
+ return target.setSavepoint(name);
+ }
+
+
+
+ public PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException
+ {
+ logSql(sql);
+ return new PreparedStatementInterceptor(this, target.prepareStatement(sql, columnNames));
+ }
+
+ public <T>T unwrap(Class<T> iface) throws SQLException
+ {
+ return target.unwrap(iface);
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+ return target.isWrapperFor(iface);
+ }
+
+ public Clob createClob() throws SQLException
+ {
+ return target.createClob();
+ }
+
+ public Blob createBlob() throws SQLException
+ {
+ return target.createBlob();
+ }
+
+ public NClob createNClob() throws SQLException
+ {
+ return target.createNClob();
+ }
+
+ public SQLXML createSQLXML() throws SQLException
+ {
+ return target.createSQLXML();
+ }
+
+ public boolean isValid(int timeout) throws SQLException
+ {
+ return target.isValid(timeout);
+ }
+
+ public void setClientInfo(String name, String value) throws SQLClientInfoException
+ {
+ target.setClientInfo(name, value);
+ }
+
+ public void setClientInfo(Properties properties) throws SQLClientInfoException
+ {
+ target.setClientInfo(properties);
+ }
+
+ public String getClientInfo(String name) throws SQLException
+ {
+ return target.getClientInfo(name);
+ }
+
+ public Properties getClientInfo() throws SQLException
+ {
+ return target.getClientInfo();
+ }
+
+ public Array createArrayOf(String typeName, Object[] elements) throws SQLException
+ {
+ return target.createArrayOf(typeName, elements);
+ }
+
+ public Struct createStruct(String typeName, Object[] attributes) throws SQLException
+ {
+ return target.createStruct(typeName, attributes);
+ }
+ }
+
+ public class StatementInterceptor
+ implements Statement
+ {
+ private final Connection con;
+ private final Statement target;
+
+ public StatementInterceptor(Connection con, Statement target)
+ {
+ this.con = con;
+ this.target = target;
+ }
+
+ public int getFetchDirection() throws SQLException
+ {
+ return target.getFetchDirection();
+ }
+
+ public int getFetchSize() throws SQLException
+ {
+ return target.getFetchSize();
+ }
+
+ public int getMaxFieldSize() throws SQLException
+ {
+ return target.getMaxFieldSize();
+ }
+
+ public int getMaxRows() throws SQLException
+ {
+ return target.getMaxRows();
+ }
+
+ public int getQueryTimeout() throws SQLException
+ {
+ return target.getQueryTimeout();
+ }
+
+ public int getResultSetConcurrency() throws SQLException
+ {
+ return target.getResultSetConcurrency();
+ }
+
+
+ public int getResultSetHoldability() throws SQLException
+ {
+ return target.getResultSetHoldability();
+ }
+
+
+ public int getResultSetType() throws SQLException
+ {
+ return target.getResultSetType();
+ }
+
+ public int getUpdateCount() throws SQLException
+ {
+ return target.getUpdateCount();
+ }
+
+ public void cancel() throws SQLException
+ {
+ target.cancel();
+ }
+
+ public void clearBatch() throws SQLException
+ {
+ target.clearBatch();
+ }
+
+ public void clearWarnings() throws SQLException
+ {
+ target.clearWarnings();
+ }
+
+ public void close() throws SQLException
+ {
+ target.close();
+ }
+
+ public boolean getMoreResults() throws SQLException
+ {
+ return target.getMoreResults();
+ }
+
+ public int[] executeBatch() throws SQLException
+ {
+ return target.executeBatch();
+ }
+
+ public void setFetchDirection(int direction) throws SQLException
+ {
+ target.setFetchDirection(direction);
+ }
+
+ public void setFetchSize(int rows) throws SQLException
+ {
+ target.setFetchSize(rows);
+ }
+
+ public void setMaxFieldSize(int max) throws SQLException
+ {
+ target.setMaxFieldSize(max);
+ }
+
+ public void setMaxRows(int max) throws SQLException
+ {
+ target.setMaxRows(max);
+ }
+
+ public void setQueryTimeout(int seconds) throws SQLException
+ {
+ target.setQueryTimeout(seconds);
+ }
+
+
+ public boolean getMoreResults(int current) throws SQLException
+ {
+ return target.getMoreResults(current);
+ }
+
+
+ public void setEscapeProcessing(boolean enable) throws SQLException
+ {
+ target.setEscapeProcessing(enable);
+ }
+
+ public int executeUpdate(String sql) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql);
+ }
+
+ public void addBatch(String sql) throws SQLException
+ {
+ logSql(sql);
+ target.addBatch(sql);
+ }
+
+ public void setCursorName(String name) throws SQLException
+ {
+ target.setCursorName(name);
+ }
+
+ public boolean execute(String sql) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql);
+ }
+
+
+ public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql, autoGeneratedKeys);
+ }
+
+
+
+ public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql, autoGeneratedKeys);
+ }
+
+
+
+ public int executeUpdate(String sql, int columnIndexes[]) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql, columnIndexes);
+ }
+
+
+
+ public boolean execute(String sql, int columnIndexes[]) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql, columnIndexes);
+ }
+
+
+ public Connection getConnection() throws SQLException
+ {
+ return con;
+ }
+
+
+ public ResultSet getGeneratedKeys() throws SQLException
+ {
+ return target.getGeneratedKeys();
+ }
+
+
+ public ResultSet getResultSet() throws SQLException
+ {
+ return target.getResultSet();
+ }
+
+ public SQLWarning getWarnings() throws SQLException
+ {
+ return target.getWarnings();
+ }
+
+
+ public int executeUpdate(String sql, String columnNames[]) throws SQLException
+ {
+ logSql(sql);
+ return target.executeUpdate(sql, columnNames);
+ }
+
+
+
+ public boolean execute(String sql, String columnNames[]) throws SQLException
+ {
+ logSql(sql);
+ return target.execute(sql, columnNames);
+ }
+
+
+ public ResultSet executeQuery(String sql) throws SQLException
+ {
+ logSql(sql);
+ return target.executeQuery(sql);
+ }
+
+ public <T>T unwrap(Class<T> iface) throws SQLException
+ {
+ return target.unwrap(iface);
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+ return target.isWrapperFor(iface);
+ }
+
+ public boolean isClosed() throws SQLException
+ {
+ return target.isClosed();
+ }
+
+ public void setPoolable(boolean poolable) throws SQLException
+ {
+ target.setPoolable(poolable);
+ }
+
+ public boolean isPoolable() throws SQLException
+ {
+ return target.isPoolable();
+ }
+ }
+
+ public class PreparedStatementInterceptor
+ extends StatementInterceptor
+ implements PreparedStatement
+ {
+ private final PreparedStatement target;
+
+ public PreparedStatementInterceptor(Connection con, PreparedStatement target)
+ {
+ super(con, target);
+ this.target = target;
+ }
+
+ public int executeUpdate() throws SQLException
+ {
+ return target.executeUpdate();
+ }
+
+ public void addBatch() throws SQLException
+ {
+ target.addBatch();
+ }
+
+ public void clearParameters() throws SQLException
+ {
+ target.clearParameters();
+ }
+
+ public boolean execute() throws SQLException
+ {
+ return target.execute();
+ }
+
+ public void setByte(int parameterIndex, byte x) throws SQLException
+ {
+ target.setByte(parameterIndex, x);
+ }
+
+ public void setDouble(int parameterIndex, double x) throws SQLException
+ {
+ target.setDouble(parameterIndex, x);
+ }
+
+ public void setFloat(int parameterIndex, float x) throws SQLException
+ {
+ target.setFloat(parameterIndex, x);
+ }
+
+ public void setInt(int parameterIndex, int x) throws SQLException
+ {
+ target.setInt(parameterIndex, x);
+ }
+
+ public void setNull(int parameterIndex, int sqlType) throws SQLException
+ {
+ target.setNull(parameterIndex, sqlType);
+ }
+
+ public void setLong(int parameterIndex, long x) throws SQLException
+ {
+ target.setLong(parameterIndex, x);
+ }
+
+ public void setShort(int parameterIndex, short x) throws SQLException
+ {
+ target.setShort(parameterIndex, x);
+ }
+
+ public void setBoolean(int parameterIndex, boolean x) throws SQLException
+ {
+ target.setBoolean(parameterIndex, x);
+ }
+
+ public void setBytes(int parameterIndex, byte x[]) throws SQLException
+ {
+ target.setBytes(parameterIndex, x);
+ }
+
+ public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
+ {
+ target.setAsciiStream(parameterIndex, x, length);
+ }
+
+ public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
+ {
+ target.setBinaryStream(parameterIndex, x, length);
+ }
+
+ public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
+ {
+ target.setUnicodeStream(parameterIndex, x, length);
+ }
+
+ public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
+ {
+ target.setCharacterStream(parameterIndex, reader, length);
+ }
+
+ public void setObject(int parameterIndex, Object x) throws SQLException
+ {
+ target.setObject(parameterIndex, x);
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
+ {
+ target.setObject(parameterIndex, x, targetSqlType);
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
+ {
+ target.setObject(parameterIndex, x, targetSqlType, scale);
+ }
+
+ public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException
+ {
+ target.setNull(paramIndex, sqlType, typeName);
+ }
+
+ public void setString(int parameterIndex, String x) throws SQLException
+ {
+ target.setString(parameterIndex, x);
+ }
+
+ public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
+ {
+ target.setBigDecimal(parameterIndex, x);
+ }
+
+
+ public void setURL(int parameterIndex, URL x) throws SQLException
+ {
+ target.setURL(parameterIndex, x);
+ }
+
+
+ public void setArray(int i, Array x) throws SQLException
+ {
+ target.setArray(i, x);
+ }
+
+ public void setBlob(int i, Blob x) throws SQLException
+ {
+ target.setBlob(i, x);
+ }
+
+ public void setClob(int i, Clob x) throws SQLException
+ {
+ target.setClob(i, x);
+ }
+
+ public void setDate(int parameterIndex, Date x) throws SQLException
+ {
+ target.setDate(parameterIndex, x);
+ }
+
+
+ public ParameterMetaData getParameterMetaData() throws SQLException
+ {
+ return target.getParameterMetaData();
+ }
+
+
+ public void setRef(int i, Ref x) throws SQLException
+ {
+ target.setRef(i, x);
+ }
+
+ public ResultSet executeQuery() throws SQLException
+ {
+ return target.executeQuery();
+ }
+
+ public ResultSetMetaData getMetaData() throws SQLException
+ {
+ return target.getMetaData();
+ }
+
+ public void setTime(int parameterIndex, Time x) throws SQLException
+ {
+ target.setTime(parameterIndex, x);
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
+ {
+ target.setTimestamp(parameterIndex, x);
+ }
+
+ public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
+ {
+ target.setDate(parameterIndex, x, cal);
+ }
+
+ public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
+ {
+ target.setTime(parameterIndex, x, cal);
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
+ {
+ target.setTimestamp(parameterIndex, x, cal);
+ }
+
+ public void setRowId(int parameterIndex, RowId x) throws SQLException
+ {
+ target.setRowId(parameterIndex, x);
+ }
+
+ public void setNString(int parameterIndex, String value) throws SQLException
+ {
+ target.setNString(parameterIndex, value);
+ }
+
+ public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
+ {
+ target.setNCharacterStream(parameterIndex, value, length);
+ }
+
+ public void setNClob(int parameterIndex, NClob value) throws SQLException
+ {
+ target.setNClob(parameterIndex, value);
+ }
+
+ public void setClob(int parameterIndex, Reader reader, long length) throws SQLException
+ {
+ target.setClob(parameterIndex, reader, length);
+ }
+
+ public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
+ {
+ target.setBlob(parameterIndex, inputStream, length);
+ }
+
+ public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
+ {
+ target.setNClob(parameterIndex, reader, length);
+ }
+
+ public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
+ {
+ target.setSQLXML(parameterIndex, xmlObject);
+ }
+
+ public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
+ {
+ target.setAsciiStream(parameterIndex, x, length);
+ }
+
+ public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
+ {
+ target.setBinaryStream(parameterIndex, x, length);
+ }
+
+ public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
+ {
+ target.setCharacterStream(parameterIndex, reader, length);
+ }
+
+ public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
+ {
+ target.setAsciiStream(parameterIndex, x);
+ }
+
+ public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
+ {
+ target.setBinaryStream(parameterIndex, x);
+ }
+
+ public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
+ {
+ target.setCharacterStream(parameterIndex, reader);
+ }
+
+ public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
+ {
+ target.setNCharacterStream(parameterIndex, value);
+ }
+
+ public void setClob(int parameterIndex, Reader reader) throws SQLException
+ {
+ target.setClob(parameterIndex, reader);
+ }
+
+ public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
+ {
+ target.setBlob(parameterIndex, inputStream);
+ }
+
+ public void setNClob(int parameterIndex, Reader reader) throws SQLException
+ {
+ target.setNClob(parameterIndex, reader);
+ }
+ }
+}
Property changes on: trunk/varia/src/main/org/jboss/varia/stats/DataSourceInterceptorJDK6.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,83 +1,83 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.varia.threaddump;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Threaddump code adapted from:
- * http://www.javaspecialists.eu/archive/Issue132.html
- */
-public class ThreadDumpBean
- implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private final Map<Thread, StackTraceElement[]> stackTraces;
-
- /**
- * Compare threads by name and id.
- */
- private static final Comparator<Thread> THREAD_COMPARATOR =
- new Comparator<Thread>()
- {
- public int compare(Thread t1, Thread t2)
- {
- int result = t1.getName().compareTo(t2.getName());
- if (result == 0)
- {
- Long tid1 = t1.getId();
- Long tid2 = t2.getId();
- result = tid1.compareTo(tid2);
- }
- return result;
- }
- };
-
- public final static void main(String[] args)
- {
- ThreadDumpBean dump = new ThreadDumpBean();
-
- System.out.println(dump.getStackTraces());
- }
-
- public ThreadDumpBean()
- {
- stackTraces = new TreeMap<Thread, StackTraceElement[]>(THREAD_COMPARATOR);
- stackTraces.putAll(Thread.getAllStackTraces());
- }
-
- public Collection<Thread> getThreads()
- {
- return stackTraces.keySet();
- }
-
- public Map<Thread, StackTraceElement[]> getStackTraces()
- {
- return stackTraces;
- }
-}
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.threaddump;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Threaddump code adapted from:
+ * http://www.javaspecialists.eu/archive/Issue132.html
+ */
+public class ThreadDumpBean
+ implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private final Map<Thread, StackTraceElement[]> stackTraces;
+
+ /**
+ * Compare threads by name and id.
+ */
+ private static final Comparator<Thread> THREAD_COMPARATOR =
+ new Comparator<Thread>()
+ {
+ public int compare(Thread t1, Thread t2)
+ {
+ int result = t1.getName().compareTo(t2.getName());
+ if (result == 0)
+ {
+ Long tid1 = t1.getId();
+ Long tid2 = t2.getId();
+ result = tid1.compareTo(tid2);
+ }
+ return result;
+ }
+ };
+
+ public final static void main(String[] args)
+ {
+ ThreadDumpBean dump = new ThreadDumpBean();
+
+ System.out.println(dump.getStackTraces());
+ }
+
+ public ThreadDumpBean()
+ {
+ stackTraces = new TreeMap<Thread, StackTraceElement[]>(THREAD_COMPARATOR);
+ stackTraces.putAll(Thread.getAllStackTraces());
+ }
+
+ public Collection<Thread> getThreads()
+ {
+ return stackTraces.keySet();
+ }
+
+ public Map<Thread, StackTraceElement[]> getStackTraces()
+ {
+ return stackTraces;
+ }
+}
+
Property changes on: trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/resources/beanshell/bsh-deployers-jboss-beans.xml
===================================================================
--- trunk/varia/src/resources/beanshell/bsh-deployers-jboss-beans.xml 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/resources/beanshell/bsh-deployers-jboss-beans.xml 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,22 +1,22 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- BSH Deployer
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- BSH parser -->
- <bean name="BSHParserDeployer" class="org.jboss.varia.deployment.LegacyBeanShellDeployer" />
-
- <!-- BSH script deployer -->
- <bean name="BSHScriptDeployer" class="org.jboss.varia.deployment.LegacyBeanShellScriptDeployer">
- <constructor><parameter><inject bean="JMXKernel" property="serviceController"/></parameter></constructor>
- </bean>
-
-<!--
- <bean name="BSHScriptClient" class="org.jboss.varia.deployment.LegacyBeanShellScriptClient">
- <constructor><parameter><inject bean="MainDeployer"/></parameter></constructor>
- </bean>
--->
-
-</deployment>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ BSH Deployer
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- BSH parser -->
+ <bean name="BSHParserDeployer" class="org.jboss.varia.deployment.LegacyBeanShellDeployer" />
+
+ <!-- BSH script deployer -->
+ <bean name="BSHScriptDeployer" class="org.jboss.varia.deployment.LegacyBeanShellScriptDeployer">
+ <constructor><parameter><inject bean="JMXKernel" property="serviceController"/></parameter></constructor>
+ </bean>
+
+<!--
+ <bean name="BSHScriptClient" class="org.jboss.varia.deployment.LegacyBeanShellScriptClient">
+ <constructor><parameter><inject bean="MainDeployer"/></parameter></constructor>
+ </bean>
+-->
+
+</deployment>
Property changes on: trunk/varia/src/resources/beanshell/bsh-deployers-jboss-beans.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/resources/jmx/html/filterView.jsp
===================================================================
--- trunk/varia/src/resources/jmx/html/filterView.jsp 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/resources/jmx/html/filterView.jsp 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,38 +1,38 @@
-<%@page contentType="text/html" import="java.util.*,org.jboss.jmx.adaptor.control.*,org.jboss.jmx.adaptor.model.*,java.io.*" %>
-<html>
-<head>
- <title>JBoss Object Index</title>
- <link rel="stylesheet" href="style_master.css" type="text/css">
- <meta http-equiv="cache-control" content="no-cache"/>
-</head>
-
-<body leftmargin="10" rightmargin="10" topmargin="10">
-
-<table width="235" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td align="center" width="235" height="105"><img src="images/logo.gif" border="0" alt="JBoss"/></td>
-</tr>
-</table>
-
-
-
-<table width="235" cellspacing="0" cellpadding="0" border="0">
-<tr><td><h2>Object Name Filter</h2></td></tr>
-<tr><td><h3><a href="HtmlAdaptor?action=displayMBeans&filter=" target="ObjectNodeView">Remove Object Name Filter</a></h3></td></tr>
-<%
- Iterator mbeans = (Iterator) Server.getDomainData("");
- int i=0;
- while( mbeans.hasNext() )
- {
- DomainData domainData = (DomainData) mbeans.next();
- out.println(" <tr>");
- out.println(" <td>");
- out.println(" <li><a href=\"HtmlAdaptor?action=displayMBeans&filter="+domainData.getDomainName()+"\" target=\"ObjectNodeView\">"+domainData.getDomainName()+"</a></li>");
- out.println(" </td>");
- out.println(" </tr>");
- }
-%>
-</table>
-
-</body>
-</html>
+<%@page contentType="text/html" import="java.util.*,org.jboss.jmx.adaptor.control.*,org.jboss.jmx.adaptor.model.*,java.io.*" %>
+<html>
+<head>
+ <title>JBoss Object Index</title>
+ <link rel="stylesheet" href="style_master.css" type="text/css">
+ <meta http-equiv="cache-control" content="no-cache"/>
+</head>
+
+<body leftmargin="10" rightmargin="10" topmargin="10">
+
+<table width="235" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td align="center" width="235" height="105"><img src="images/logo.gif" border="0" alt="JBoss"/></td>
+</tr>
+</table>
+
+
+
+<table width="235" cellspacing="0" cellpadding="0" border="0">
+<tr><td><h2>Object Name Filter</h2></td></tr>
+<tr><td><h3><a href="HtmlAdaptor?action=displayMBeans&filter=" target="ObjectNodeView">Remove Object Name Filter</a></h3></td></tr>
+<%
+ Iterator mbeans = (Iterator) Server.getDomainData("");
+ int i=0;
+ while( mbeans.hasNext() )
+ {
+ DomainData domainData = (DomainData) mbeans.next();
+ out.println(" <tr>");
+ out.println(" <td>");
+ out.println(" <li><a href=\"HtmlAdaptor?action=displayMBeans&filter="+domainData.getDomainName()+"\" target=\"ObjectNodeView\">"+domainData.getDomainName()+"</a></li>");
+ out.println(" </td>");
+ out.println(" </tr>");
+ }
+%>
+</table>
+
+</body>
+</html>
Property changes on: trunk/varia/src/resources/jmx/html/filterView.jsp
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/resources/jmx/html/genericError.jsp
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/resources/jmx/html/images/logo.gif
___________________________________________________________________
Name: svn:mime-type
- application/octet-stream
+ image/gif
Modified: trunk/varia/src/resources/services/deployment/templates/jms-queue/template-config.xml
===================================================================
--- trunk/varia/src/resources/services/deployment/templates/jms-queue/template-config.xml 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/resources/services/deployment/templates/jms-queue/template-config.xml 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,51 +1,51 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Example template configuration that produces a JBoss messaging
- queue deployment descriptor.
-
- Documentation for the deployment service can be found at:
- http://www.jboss.org/wiki/Wiki.jsp?page=DeploymentService
--->
-<template-config template="vm/jms-queue.xml.vm" extension="-service.xml">
-
- <property-list>
- <!-- if type not specified, java.lang.String is assumed -->
- <!-- a value must be supplied at runtime, or an exception will be thrown -->
- <property name="Name"/>
-
- <property name="JNDIName" type="java.lang.String" optional="true"/>
-
- <property name="DLQ" type="java.lang.String" optional="true"/>
-
- <property name="ExpiryQueue" type="java.lang.String" optional="true"/>
-
- <property name="RedeliveryDelay" type="java.lang.Long" optional="true"/>
-
- <property name="MaxSize" type="java.lang.Integer" optional="true">
- <default-value>-1</default-value>
- </property>
-
- <property name="FullSize" type="java.lang.Integer" optional="true">
- <default-value>75000</default-value>
- </property>
-
- <property name="PageSize" type="java.lang.Integer" optional="true">
- <default-value>2000</default-value>
- </property>
-
- <property name="DownCacheSize" type="java.lang.Integer" optional="true">
- <default-value>2000</default-value>
- </property>
-
- <property name="Clustered" type="java.lang.Boolean" optional="true"/>
-
- <property name="MessageCounterHistoryDayLimit" type="java.lang.Integer" optional="true">
- <default-value>-1</default-value>
- </property>
-
- <!-- arrays and generally any valid java/user class is permitted -->
- <property name="SecurityRoles" type="[Ljava.lang.String;" optional="true"/>
-
- </property-list>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Example template configuration that produces a JBoss messaging
+ queue deployment descriptor.
+
+ Documentation for the deployment service can be found at:
+ http://www.jboss.org/wiki/Wiki.jsp?page=DeploymentService
+-->
+<template-config template="vm/jms-queue.xml.vm" extension="-service.xml">
+
+ <property-list>
+ <!-- if type not specified, java.lang.String is assumed -->
+ <!-- a value must be supplied at runtime, or an exception will be thrown -->
+ <property name="Name"/>
+
+ <property name="JNDIName" type="java.lang.String" optional="true"/>
+
+ <property name="DLQ" type="java.lang.String" optional="true"/>
+
+ <property name="ExpiryQueue" type="java.lang.String" optional="true"/>
+
+ <property name="RedeliveryDelay" type="java.lang.Long" optional="true"/>
+
+ <property name="MaxSize" type="java.lang.Integer" optional="true">
+ <default-value>-1</default-value>
+ </property>
+
+ <property name="FullSize" type="java.lang.Integer" optional="true">
+ <default-value>75000</default-value>
+ </property>
+
+ <property name="PageSize" type="java.lang.Integer" optional="true">
+ <default-value>2000</default-value>
+ </property>
+
+ <property name="DownCacheSize" type="java.lang.Integer" optional="true">
+ <default-value>2000</default-value>
+ </property>
+
+ <property name="Clustered" type="java.lang.Boolean" optional="true"/>
+
+ <property name="MessageCounterHistoryDayLimit" type="java.lang.Integer" optional="true">
+ <default-value>-1</default-value>
+ </property>
+
+ <!-- arrays and generally any valid java/user class is permitted -->
+ <property name="SecurityRoles" type="[Ljava.lang.String;" optional="true"/>
+
+ </property-list>
+
</template-config>
\ No newline at end of file
Property changes on: trunk/varia/src/resources/services/deployment/templates/jms-queue/template-config.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/resources/services/deployment/templates/jms-topic/template-config.xml
===================================================================
--- trunk/varia/src/resources/services/deployment/templates/jms-topic/template-config.xml 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/resources/services/deployment/templates/jms-topic/template-config.xml 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,51 +1,51 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Example template configuration that produces a JBoss messaging
- topic deployment descriptor.
-
- Documentation for the deployment service can be found at:
- http://www.jboss.org/wiki/Wiki.jsp?page=DeploymentService
--->
-<template-config template="vm/jms-topic.xml.vm" extension="-service.xml">
-
- <property-list>
- <!-- if type not specified, java.lang.String is assumed -->
- <!-- a value must be supplied at runtime, or an exception will be thrown -->
- <property name="Name"/>
-
- <property name="JNDIName" type="java.lang.String" optional="true"/>
-
- <property name="DLQ" type="java.lang.String" optional="true"/>
-
- <property name="ExpiryQueue" type="java.lang.String" optional="true"/>
-
- <property name="RedeliveryDelay" type="java.lang.Long" optional="true"/>
-
- <property name="MaxSize" type="java.lang.Integer" optional="true">
- <default-value>-1</default-value>
- </property>
-
- <property name="FullSize" type="java.lang.Integer" optional="true">
- <default-value>75000</default-value>
- </property>
-
- <property name="PageSize" type="java.lang.Integer" optional="true">
- <default-value>2000</default-value>
- </property>
-
- <property name="DownCacheSize" type="java.lang.Integer" optional="true">
- <default-value>2000</default-value>
- </property>
-
- <property name="Clustered" type="java.lang.Boolean" optional="true"/>
-
- <property name="MessageCounterHistoryDayLimit" type="java.lang.Integer" optional="true">
- <default-value>-1</default-value>
- </property>
-
- <!-- arrays and generally any valid java/user class is permitted -->
- <property name="SecurityRoles" type="[Ljava.lang.String;" optional="true"/>
-
- </property-list>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Example template configuration that produces a JBoss messaging
+ topic deployment descriptor.
+
+ Documentation for the deployment service can be found at:
+ http://www.jboss.org/wiki/Wiki.jsp?page=DeploymentService
+-->
+<template-config template="vm/jms-topic.xml.vm" extension="-service.xml">
+
+ <property-list>
+ <!-- if type not specified, java.lang.String is assumed -->
+ <!-- a value must be supplied at runtime, or an exception will be thrown -->
+ <property name="Name"/>
+
+ <property name="JNDIName" type="java.lang.String" optional="true"/>
+
+ <property name="DLQ" type="java.lang.String" optional="true"/>
+
+ <property name="ExpiryQueue" type="java.lang.String" optional="true"/>
+
+ <property name="RedeliveryDelay" type="java.lang.Long" optional="true"/>
+
+ <property name="MaxSize" type="java.lang.Integer" optional="true">
+ <default-value>-1</default-value>
+ </property>
+
+ <property name="FullSize" type="java.lang.Integer" optional="true">
+ <default-value>75000</default-value>
+ </property>
+
+ <property name="PageSize" type="java.lang.Integer" optional="true">
+ <default-value>2000</default-value>
+ </property>
+
+ <property name="DownCacheSize" type="java.lang.Integer" optional="true">
+ <default-value>2000</default-value>
+ </property>
+
+ <property name="Clustered" type="java.lang.Boolean" optional="true"/>
+
+ <property name="MessageCounterHistoryDayLimit" type="java.lang.Integer" optional="true">
+ <default-value>-1</default-value>
+ </property>
+
+ <!-- arrays and generally any valid java/user class is permitted -->
+ <property name="SecurityRoles" type="[Ljava.lang.String;" optional="true"/>
+
+ </property-list>
+
</template-config>
\ No newline at end of file
Property changes on: trunk/varia/src/resources/services/deployment/templates/jms-topic/template-config.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/alt_input.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/input.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt_input.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/resources/varia/threaddump/index.jsp
===================================================================
--- trunk/varia/src/resources/varia/threaddump/index.jsp 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/resources/varia/threaddump/index.jsp 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,37 +1,37 @@
-<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
-
-<jsp:useBean id="threadDump"
- class="org.jboss.varia.threaddump.ThreadDumpBean"
- scope="request"/>
-
-<html>
-<body>
-<h2>Thread Summary</h2>
-<table cellpadding="5" cellspacing="5">
- <tr>
- <th>Thread</th>
- <th>State</th>
- <th>Priority</th>
- <th>Daemon</th>
- </tr>
- <c:forEach items="${threadDump.threads}" var="thr">
- <tr>
- <td><c:out value='<a href="#${thr.id}">${thr.name}</a>' escapeXml="false"/></td>
- <td><c:out value="${thr.state}"/></td>
- <td><c:out value="${thr.priority}"/></td>
- <td><c:out value="${thr.daemon}"/></td>
- </tr>
- </c:forEach>
-</table>
-
-<h2>Thread Stack Traces</h2>
-<c:forEach items="${threadDump.stackTraces}" var="trace">
- <h4><c:out value='<a name="${trace.key.id}">${trace.key}</a>' escapeXml="false"/></h4>
- <pre>
- <c:forEach items="${trace.value}" var="traceline">
- at <c:out value="${traceline}"/></c:forEach>
- </pre>
-</c:forEach>
-
-</body>
-</html>
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
+
+<jsp:useBean id="threadDump"
+ class="org.jboss.varia.threaddump.ThreadDumpBean"
+ scope="request"/>
+
+<html>
+<body>
+<h2>Thread Summary</h2>
+<table cellpadding="5" cellspacing="5">
+ <tr>
+ <th>Thread</th>
+ <th>State</th>
+ <th>Priority</th>
+ <th>Daemon</th>
+ </tr>
+ <c:forEach items="${threadDump.threads}" var="thr">
+ <tr>
+ <td><c:out value='<a href="#${thr.id}">${thr.name}</a>' escapeXml="false"/></td>
+ <td><c:out value="${thr.state}"/></td>
+ <td><c:out value="${thr.priority}"/></td>
+ <td><c:out value="${thr.daemon}"/></td>
+ </tr>
+ </c:forEach>
+</table>
+
+<h2>Thread Stack Traces</h2>
+<c:forEach items="${threadDump.stackTraces}" var="trace">
+ <h4><c:out value='<a name="${trace.key.id}">${trace.key}</a>' escapeXml="false"/></h4>
+ <pre>
+ <c:forEach items="${trace.value}" var="traceline">
+ at <c:out value="${traceline}"/></c:forEach>
+ </pre>
+</c:forEach>
+
+</body>
+</html>
Property changes on: trunk/varia/src/resources/varia/threaddump/index.jsp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/resources/varia/threaddump/web.xml
===================================================================
--- trunk/varia/src/resources/varia/threaddump/web.xml 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/resources/varia/threaddump/web.xml 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,7 +1,7 @@
-<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-
-<web-app>
+<?xml version="1.0"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
</web-app>
\ No newline at end of file
Property changes on: trunk/varia/src/resources/varia/threaddump/web.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,121 +1,121 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import org.jboss.services.binding.ServiceBindingManager;
-import org.jboss.services.binding.ServiceBindingManager.BindingType;
-import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-
-/**
- * Tests of {@link ServiceBindingManager#getServiceBindingValueSource(org.jboss.bindings.ServiceBinding, BindingType)}
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1 $
- */
-public class DefaultServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- /**
- * Create a new DefaultServiceBindingValueSourceUnitTestCase.
- *
- * @param arg0
- */
- public DefaultServiceBindingValueSourceUnitTestCase(String arg0)
- {
- super(arg0);
- }
-
- public void testInjectedSource() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource("test");
- binding.setServiceBindingValueSource(source);
- assertEquals(source, ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC));
- }
-
- public void testInjectedSourceClassName() throws Exception
- {
- binding.setServiceBindingValueSourceClassName(MockServiceBindingValueSource.class.getName());
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC) instanceof MockServiceBindingValueSource);
- }
-
- public void testInt() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INT) instanceof SimpleServiceBindingValueSourceImpl);
- }
-
- public void testInetAddress() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INETADDRESS) instanceof SimpleServiceBindingValueSourceImpl);
- }
-
- public void testString() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.STRING) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testElement() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testResource() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testURL() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testElementXSLT() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- public void testResourceXSLT() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- public void testURLXSLT() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- public void testGeneric() throws Exception
- {
- try
- {
- ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC);
- fail("unknown generic should fail");
- }
- catch(IllegalStateException good) {}
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import org.jboss.services.binding.ServiceBindingManager;
+import org.jboss.services.binding.ServiceBindingManager.BindingType;
+import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+
+/**
+ * Tests of {@link ServiceBindingManager#getServiceBindingValueSource(org.jboss.bindings.ServiceBinding, BindingType)}
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class DefaultServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{
+ /**
+ * Create a new DefaultServiceBindingValueSourceUnitTestCase.
+ *
+ * @param arg0
+ */
+ public DefaultServiceBindingValueSourceUnitTestCase(String arg0)
+ {
+ super(arg0);
+ }
+
+ public void testInjectedSource() throws Exception
+ {
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource("test");
+ binding.setServiceBindingValueSource(source);
+ assertEquals(source, ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC));
+ }
+
+ public void testInjectedSourceClassName() throws Exception
+ {
+ binding.setServiceBindingValueSourceClassName(MockServiceBindingValueSource.class.getName());
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC) instanceof MockServiceBindingValueSource);
+ }
+
+ public void testInt() throws Exception
+ {
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INT) instanceof SimpleServiceBindingValueSourceImpl);
+ }
+
+ public void testInetAddress() throws Exception
+ {
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INETADDRESS) instanceof SimpleServiceBindingValueSourceImpl);
+ }
+
+ public void testString() throws Exception
+ {
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.STRING) instanceof StringReplacementServiceBindingValueSourceImpl);
+ }
+
+ public void testElement() throws Exception
+ {
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof StringReplacementServiceBindingValueSourceImpl);
+ }
+
+ public void testResource() throws Exception
+ {
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof StringReplacementServiceBindingValueSourceImpl);
+ }
+
+ public void testURL() throws Exception
+ {
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof StringReplacementServiceBindingValueSourceImpl);
+ }
+
+ public void testElementXSLT() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof XSLTServiceBindingValueSourceImpl);
+ }
+
+ public void testResourceXSLT() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof XSLTServiceBindingValueSourceImpl);
+ }
+
+ public void testURLXSLT() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+ assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof XSLTServiceBindingValueSourceImpl);
+ }
+
+ public void testGeneric() throws Exception
+ {
+ try
+ {
+ ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC);
+ fail("unknown generic should fail");
+ }
+ catch(IllegalStateException good) {}
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,137 +1,137 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.jboss.services.binding.DuplicateServiceException;
-import org.jboss.services.binding.NoSuchBindingException;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingStore;
-
-/**
- * Mock implementation of ServiceBindingStore. Stores a single ServiceBinding.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MockServiceBindingStore implements ServiceBindingStore
-{
- public static final String HOSTNAME = "192.168.1.10";
-
- private final String serverName;
- private ServiceBinding binding;
-
- public MockServiceBindingStore(ServiceBinding binding, String serverName)
- {
- this.binding = binding;
- this.serverName = serverName;
- }
-
- public void addServiceBinding(String serverName, ServiceBinding binding) throws DuplicateServiceException
- {
- throw new UnsupportedOperationException("unimplemented");
- }
-
- public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
- throws NoSuchBindingException
- {
- if (this.binding == null
- || this.serverName.equals(serverName) == false
- || this.binding.getServiceName().equals(serviceName) == false
- || safeEquals(this.binding.getBindingName(), bindingName) == false)
- {
- throw new NoSuchBindingException(serverName, serviceName, bindingName);
- }
-
- return binding;
- }
-
- public void removeServiceBinding(String serverName, ServiceBinding binding)
- {
- throw new UnsupportedOperationException("unimplemented");
- }
-
- public void removeServiceBinding(String serverName, String serviceName, String bindingName)
- {
- throw new UnsupportedOperationException("unimplemented");
- }
-
- public void addServiceBinding(ServiceBinding binding) throws DuplicateServiceException
- {
- if (this.binding != null)
- throw new IllegalStateException("MockServiceBindingStore already has a binding");
- this.binding = binding;
- }
-
- public InetAddress getDefaultBindAddress(String serverName)
- {
- try
- {
- return InetAddress.getByName(HOSTNAME);
- }
- catch (UnknownHostException e)
- {
- throw new IllegalStateException("Can't create InetAddress for " + HOSTNAME, e);
- }
- }
-
- public String getDefaultHostName(String serverName)
- {
- return HOSTNAME;
- }
-
- public int getDefaultPortOffset(String serverName)
- {
- return 1000;
- }
-
- public void removeServiceBinding(ServiceBinding binding)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void removeServiceBinding(String serviceName, String bindingName)
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * Set the binding.
- *
- * @param binding The binding to set.
- */
- public void setBinding(ServiceBinding binding)
- {
- this.binding = binding;
- }
-
- private boolean safeEquals(Object a, Object b)
- {
- return (a == b || (a != null && a.equals(b)));
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.jboss.services.binding.DuplicateServiceException;
+import org.jboss.services.binding.NoSuchBindingException;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingStore;
+
+/**
+ * Mock implementation of ServiceBindingStore. Stores a single ServiceBinding.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class MockServiceBindingStore implements ServiceBindingStore
+{
+ public static final String HOSTNAME = "192.168.1.10";
+
+ private final String serverName;
+ private ServiceBinding binding;
+
+ public MockServiceBindingStore(ServiceBinding binding, String serverName)
+ {
+ this.binding = binding;
+ this.serverName = serverName;
+ }
+
+ public void addServiceBinding(String serverName, ServiceBinding binding) throws DuplicateServiceException
+ {
+ throw new UnsupportedOperationException("unimplemented");
+ }
+
+ public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
+ throws NoSuchBindingException
+ {
+ if (this.binding == null
+ || this.serverName.equals(serverName) == false
+ || this.binding.getServiceName().equals(serviceName) == false
+ || safeEquals(this.binding.getBindingName(), bindingName) == false)
+ {
+ throw new NoSuchBindingException(serverName, serviceName, bindingName);
+ }
+
+ return binding;
+ }
+
+ public void removeServiceBinding(String serverName, ServiceBinding binding)
+ {
+ throw new UnsupportedOperationException("unimplemented");
+ }
+
+ public void removeServiceBinding(String serverName, String serviceName, String bindingName)
+ {
+ throw new UnsupportedOperationException("unimplemented");
+ }
+
+ public void addServiceBinding(ServiceBinding binding) throws DuplicateServiceException
+ {
+ if (this.binding != null)
+ throw new IllegalStateException("MockServiceBindingStore already has a binding");
+ this.binding = binding;
+ }
+
+ public InetAddress getDefaultBindAddress(String serverName)
+ {
+ try
+ {
+ return InetAddress.getByName(HOSTNAME);
+ }
+ catch (UnknownHostException e)
+ {
+ throw new IllegalStateException("Can't create InetAddress for " + HOSTNAME, e);
+ }
+ }
+
+ public String getDefaultHostName(String serverName)
+ {
+ return HOSTNAME;
+ }
+
+ public int getDefaultPortOffset(String serverName)
+ {
+ return 1000;
+ }
+
+ public void removeServiceBinding(ServiceBinding binding)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeServiceBinding(String serviceName, String bindingName)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Set the binding.
+ *
+ * @param binding The binding to set.
+ */
+ public void setBinding(ServiceBinding binding)
+ {
+ this.binding = binding;
+ }
+
+ private boolean safeEquals(Object a, Object b)
+ {
+ return (a == b || (a != null && a.equals(b)));
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,61 +1,61 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingValueSource;
-
-/**
- * Mock implementation of ServiceBindingValueSource. Returms an injected return
- * value; keeps a reference to passed in params so the test driver can analyze them.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MockServiceBindingValueSource implements ServiceBindingValueSource
-{
- private final Object returnValue;
- private Object[] params;
-
- public MockServiceBindingValueSource()
- {
- this.returnValue = null;
- }
-
- public MockServiceBindingValueSource(Object returnValue)
- {
- this.returnValue = returnValue;
- }
-
- public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
- {
- this.params = params;
- return returnValue;
- }
-
- public Object[] getParams()
- {
- return params;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingValueSource;
+
+/**
+ * Mock implementation of ServiceBindingValueSource. Returms an injected return
+ * value; keeps a reference to passed in params so the test driver can analyze them.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class MockServiceBindingValueSource implements ServiceBindingValueSource
+{
+ private final Object returnValue;
+ private Object[] params;
+
+ public MockServiceBindingValueSource()
+ {
+ this.returnValue = null;
+ }
+
+ public MockServiceBindingValueSource(Object returnValue)
+ {
+ this.returnValue = returnValue;
+ }
+
+ public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+ {
+ this.params = params;
+ return returnValue;
+ }
+
+ public Object[] getParams()
+ {
+ return params;
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,372 +1,372 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.net.InetAddress;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.DuplicateServiceException;
-import org.jboss.services.binding.NoSuchBindingException;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.PojoServiceBindingStore;
-import org.jboss.services.binding.impl.ServiceBindingSet;
-
-/**
- * Tests of PojoServiceBindingStore.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class PojoServiceBindingStoreUnitTestCase extends TestCase
-{
- private static final String A = "A";
- private static final String B = "B";
- private static final String C = "C";
- private static final String D = "D";
-
- private static ServiceBinding AA;
- private static ServiceBinding AB;
- private static ServiceBinding Anull;
-
- private Map<String, ServiceBindingSet> bindings = new HashMap<String, ServiceBindingSet>();
-
- /**
- * Create a new PojoServiceBindingStoreUnitTestCase.
- *
- * @param name
- */
- public PojoServiceBindingStoreUnitTestCase(String name)
- {
- super(name);
- }
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- AA = new ServiceBinding(A, A, "localhost", 1);
- AB = new ServiceBinding(A, B, "localhost", 1);
- Anull = new ServiceBinding(A, null, "localhost", 1);
-
- Set<ServiceBinding> set = new HashSet<ServiceBinding>();
- set.addAll(Arrays.asList(AA, AB, Anull));
- ServiceBindingSet sbs = new ServiceBindingSet(set);
- bindings.put(A, sbs);
- bindings.put(B, sbs);
- bindings.put(C, sbs);
- }
-
- public void testGetServiceBinding() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
-
- assertEquals(AA, store.getServiceBinding(A, A, A));
- assertEquals(AA, store.getServiceBinding(B, A, A));
- assertEquals(AA, store.getServiceBinding(C, A, A));
-
- assertEquals(AB, store.getServiceBinding(A, A, B));
- assertEquals(AB, store.getServiceBinding(B, A, B));
- assertEquals(AB, store.getServiceBinding(C, A, B));
-
- assertEquals(Anull, store.getServiceBinding(A, A, null));
- assertEquals(Anull, store.getServiceBinding(B, A, null));
- assertEquals(Anull, store.getServiceBinding(C, A, null));
-
- try
- {
- store.getServiceBinding(D, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(A, B, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(A, B, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
- }
-
- public void testAddServiceBinding() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
-
- ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
- store.addServiceBinding(A, new1);
- store.addServiceBinding(B, new1);
- store.addServiceBinding(C, new1);
-
- assertEquals(new1, store.getServiceBinding(A, B, A));
- assertEquals(new1, store.getServiceBinding(B, B, A));
- assertEquals(new1, store.getServiceBinding(C, B, A));
-
- ServiceBinding new2 = new ServiceBinding(B, A, "localhost", 2);
- try
- {
- store.addServiceBinding(D, new2);
- fail("add for unknown binding set succeeded");
- }
- catch (IllegalArgumentException good) {}
-
- try
- {
- store.addServiceBinding(A, new2);
- fail("duplicate add succeeded");
- }
- catch (DuplicateServiceException good) {}
- }
-
- public void testRemoveServiceBinding() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
-
- store.removeServiceBinding(A, AA);
-
- try
- {
- store.getServiceBinding(A, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(B, A, A);
-
- try
- {
- store.getServiceBinding(B, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(A, Anull);
-
- try
- {
- store.getServiceBinding(A, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(B, A, null);
-
- try
- {
- store.getServiceBinding(B, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
- store.removeServiceBinding(A, new1);
- store.removeServiceBinding(A, B, A);
- }
-
-
- public void testAddServiceBindingToAll() throws Exception
- {
- Set<ServiceBinding> set = new HashSet<ServiceBinding>();
- set.addAll(Arrays.asList(AA, AB, Anull));
-
- ServiceBindingSet sbs = new ServiceBindingSet(set, 10, null);
- Map<String, ServiceBindingSet> map = new HashMap<String, ServiceBindingSet>();
- map.put(A, sbs);
-
- sbs = new ServiceBindingSet(set, 20, "localhost");
- map.put(B, sbs);
-
- sbs = new ServiceBindingSet(set, 30, "192.168.0.10");
- map.put(C, sbs);
-
- PojoServiceBindingStore store = new PojoServiceBindingStore(map);
-
- ServiceBinding new1 = new ServiceBinding(B, A, "192.168.0.22", 1);
- store.addServiceBinding(new1);
-
- InetAddress address = InetAddress.getByName("192.168.0.22");
-
- ServiceBinding got = store.getServiceBinding(A, B, A);
- assertEquals(new1, got);
- assertEquals(11, got.getPort());
- assertEquals("192.168.0.22", got.getHostName());
- assertEquals(address, got.getBindAddress());
-
- got = store.getServiceBinding(B, B, A);
- assertEquals(new1, got);
- assertEquals(21, got.getPort());
- assertEquals("192.168.0.22", got.getHostName());
- assertEquals(address, got.getBindAddress());
-
- got = store.getServiceBinding(C, B, A);
- assertEquals(new1, got);
- assertEquals(31, got.getPort());
- assertEquals("192.168.0.22", got.getHostName());
- assertEquals(address, got.getBindAddress());
-
- ServiceBinding new2 = new ServiceBinding(B, A, "localhost", 2);
- try
- {
- store.addServiceBinding(new2);
- fail("duplicate add succeeded");
- }
- catch (DuplicateServiceException good) {}
-
- ServiceBinding new3 = new ServiceBinding(C, C, null, 3);
- store.addServiceBinding(new3);
-
- got = store.getServiceBinding(A, C, C);
- assertEquals(new3, got);
- assertEquals(13, got.getPort());
- assertNull(got.getHostName());
- assertEquals(InetAddress.getByName(null), got.getBindAddress());
-
- got = store.getServiceBinding(B, C, C);
- assertEquals(new3, got);
- assertEquals(23, got.getPort());
- assertEquals("localhost", got.getHostName());
- assertEquals(InetAddress.getByName("localhost"), got.getBindAddress());
-
- got = store.getServiceBinding(C, C, C);
- assertEquals(new3, got);
- assertEquals(33, got.getPort());
- assertEquals("192.168.0.10", got.getHostName());
- assertEquals(InetAddress.getByName("192.168.0.10"), got.getBindAddress());
-
- }
-
- public void testRemoveServiceBindingFromAll() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
-
- store.removeServiceBinding(AA);
-
- try
- {
- store.getServiceBinding(A, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(B, A, A);
-
- try
- {
- store.getServiceBinding(B, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(C, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- String nullA = null;
- store.removeServiceBinding(A, nullA);
-
- try
- {
- store.getServiceBinding(A, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(B, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(C, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
- store.removeServiceBinding(new1);
- store.removeServiceBinding(B, A);
- }
-
- public void testDefaultDefaults() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
-
- String[] names = {A, B, C};
-
- for (String name :names)
- {
- assertNull(store.getDefaultHostName(name));
- assertNull(store.getDefaultBindAddress(name));
- assertEquals(0, store.getDefaultPortOffset(name));
- }
- }
-
- public void testDefaults() throws Exception
- {
- Set<ServiceBinding> set = new HashSet<ServiceBinding>();
- set.addAll(Arrays.asList(AA, AB, Anull));
-
- ServiceBindingSet sbs = new ServiceBindingSet(set, 10, null);
- Map<String, ServiceBindingSet> map = new HashMap<String, ServiceBindingSet>();
- map.put(A, sbs);
-
- sbs = new ServiceBindingSet(set, 20, "localhost");
- map.put(B, sbs);
-
- sbs = new ServiceBindingSet(set, 30, "192.168.0.10");
- map.put(C, sbs);
-
- PojoServiceBindingStore store = new PojoServiceBindingStore(map);
-
- assertNull(store.getDefaultHostName(A));
- assertNull(store.getDefaultBindAddress(A));
- assertEquals(10, store.getDefaultPortOffset(A));
-
- assertEquals("localhost", store.getDefaultHostName(B));
- assertEquals(InetAddress.getByName("localhost"), store.getDefaultBindAddress(B));
- assertEquals(20, store.getDefaultPortOffset(B));
-
- assertEquals("192.168.0.10", store.getDefaultHostName(C));
- assertEquals(InetAddress.getByName("192.168.0.10"), store.getDefaultBindAddress(C));
- assertEquals(30, store.getDefaultPortOffset(C));
- }
-
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.DuplicateServiceException;
+import org.jboss.services.binding.NoSuchBindingException;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.PojoServiceBindingStore;
+import org.jboss.services.binding.impl.ServiceBindingSet;
+
+/**
+ * Tests of PojoServiceBindingStore.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class PojoServiceBindingStoreUnitTestCase extends TestCase
+{
+ private static final String A = "A";
+ private static final String B = "B";
+ private static final String C = "C";
+ private static final String D = "D";
+
+ private static ServiceBinding AA;
+ private static ServiceBinding AB;
+ private static ServiceBinding Anull;
+
+ private Map<String, ServiceBindingSet> bindings = new HashMap<String, ServiceBindingSet>();
+
+ /**
+ * Create a new PojoServiceBindingStoreUnitTestCase.
+ *
+ * @param name
+ */
+ public PojoServiceBindingStoreUnitTestCase(String name)
+ {
+ super(name);
+ }
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ AA = new ServiceBinding(A, A, "localhost", 1);
+ AB = new ServiceBinding(A, B, "localhost", 1);
+ Anull = new ServiceBinding(A, null, "localhost", 1);
+
+ Set<ServiceBinding> set = new HashSet<ServiceBinding>();
+ set.addAll(Arrays.asList(AA, AB, Anull));
+ ServiceBindingSet sbs = new ServiceBindingSet(set);
+ bindings.put(A, sbs);
+ bindings.put(B, sbs);
+ bindings.put(C, sbs);
+ }
+
+ public void testGetServiceBinding() throws Exception
+ {
+ PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+
+ assertEquals(AA, store.getServiceBinding(A, A, A));
+ assertEquals(AA, store.getServiceBinding(B, A, A));
+ assertEquals(AA, store.getServiceBinding(C, A, A));
+
+ assertEquals(AB, store.getServiceBinding(A, A, B));
+ assertEquals(AB, store.getServiceBinding(B, A, B));
+ assertEquals(AB, store.getServiceBinding(C, A, B));
+
+ assertEquals(Anull, store.getServiceBinding(A, A, null));
+ assertEquals(Anull, store.getServiceBinding(B, A, null));
+ assertEquals(Anull, store.getServiceBinding(C, A, null));
+
+ try
+ {
+ store.getServiceBinding(D, A, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ try
+ {
+ store.getServiceBinding(A, B, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ try
+ {
+ store.getServiceBinding(A, B, null);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+ }
+
+ public void testAddServiceBinding() throws Exception
+ {
+ PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+
+ ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
+ store.addServiceBinding(A, new1);
+ store.addServiceBinding(B, new1);
+ store.addServiceBinding(C, new1);
+
+ assertEquals(new1, store.getServiceBinding(A, B, A));
+ assertEquals(new1, store.getServiceBinding(B, B, A));
+ assertEquals(new1, store.getServiceBinding(C, B, A));
+
+ ServiceBinding new2 = new ServiceBinding(B, A, "localhost", 2);
+ try
+ {
+ store.addServiceBinding(D, new2);
+ fail("add for unknown binding set succeeded");
+ }
+ catch (IllegalArgumentException good) {}
+
+ try
+ {
+ store.addServiceBinding(A, new2);
+ fail("duplicate add succeeded");
+ }
+ catch (DuplicateServiceException good) {}
+ }
+
+ public void testRemoveServiceBinding() throws Exception
+ {
+ PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+
+ store.removeServiceBinding(A, AA);
+
+ try
+ {
+ store.getServiceBinding(A, A, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ store.removeServiceBinding(B, A, A);
+
+ try
+ {
+ store.getServiceBinding(B, A, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ store.removeServiceBinding(A, Anull);
+
+ try
+ {
+ store.getServiceBinding(A, A, null);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ store.removeServiceBinding(B, A, null);
+
+ try
+ {
+ store.getServiceBinding(B, A, null);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
+ store.removeServiceBinding(A, new1);
+ store.removeServiceBinding(A, B, A);
+ }
+
+
+ public void testAddServiceBindingToAll() throws Exception
+ {
+ Set<ServiceBinding> set = new HashSet<ServiceBinding>();
+ set.addAll(Arrays.asList(AA, AB, Anull));
+
+ ServiceBindingSet sbs = new ServiceBindingSet(set, 10, null);
+ Map<String, ServiceBindingSet> map = new HashMap<String, ServiceBindingSet>();
+ map.put(A, sbs);
+
+ sbs = new ServiceBindingSet(set, 20, "localhost");
+ map.put(B, sbs);
+
+ sbs = new ServiceBindingSet(set, 30, "192.168.0.10");
+ map.put(C, sbs);
+
+ PojoServiceBindingStore store = new PojoServiceBindingStore(map);
+
+ ServiceBinding new1 = new ServiceBinding(B, A, "192.168.0.22", 1);
+ store.addServiceBinding(new1);
+
+ InetAddress address = InetAddress.getByName("192.168.0.22");
+
+ ServiceBinding got = store.getServiceBinding(A, B, A);
+ assertEquals(new1, got);
+ assertEquals(11, got.getPort());
+ assertEquals("192.168.0.22", got.getHostName());
+ assertEquals(address, got.getBindAddress());
+
+ got = store.getServiceBinding(B, B, A);
+ assertEquals(new1, got);
+ assertEquals(21, got.getPort());
+ assertEquals("192.168.0.22", got.getHostName());
+ assertEquals(address, got.getBindAddress());
+
+ got = store.getServiceBinding(C, B, A);
+ assertEquals(new1, got);
+ assertEquals(31, got.getPort());
+ assertEquals("192.168.0.22", got.getHostName());
+ assertEquals(address, got.getBindAddress());
+
+ ServiceBinding new2 = new ServiceBinding(B, A, "localhost", 2);
+ try
+ {
+ store.addServiceBinding(new2);
+ fail("duplicate add succeeded");
+ }
+ catch (DuplicateServiceException good) {}
+
+ ServiceBinding new3 = new ServiceBinding(C, C, null, 3);
+ store.addServiceBinding(new3);
+
+ got = store.getServiceBinding(A, C, C);
+ assertEquals(new3, got);
+ assertEquals(13, got.getPort());
+ assertNull(got.getHostName());
+ assertEquals(InetAddress.getByName(null), got.getBindAddress());
+
+ got = store.getServiceBinding(B, C, C);
+ assertEquals(new3, got);
+ assertEquals(23, got.getPort());
+ assertEquals("localhost", got.getHostName());
+ assertEquals(InetAddress.getByName("localhost"), got.getBindAddress());
+
+ got = store.getServiceBinding(C, C, C);
+ assertEquals(new3, got);
+ assertEquals(33, got.getPort());
+ assertEquals("192.168.0.10", got.getHostName());
+ assertEquals(InetAddress.getByName("192.168.0.10"), got.getBindAddress());
+
+ }
+
+ public void testRemoveServiceBindingFromAll() throws Exception
+ {
+ PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+
+ store.removeServiceBinding(AA);
+
+ try
+ {
+ store.getServiceBinding(A, A, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ store.removeServiceBinding(B, A, A);
+
+ try
+ {
+ store.getServiceBinding(B, A, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ try
+ {
+ store.getServiceBinding(C, A, A);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ String nullA = null;
+ store.removeServiceBinding(A, nullA);
+
+ try
+ {
+ store.getServiceBinding(A, A, null);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ try
+ {
+ store.getServiceBinding(B, A, null);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ try
+ {
+ store.getServiceBinding(C, A, null);
+ fail("invalid");
+ }
+ catch (NoSuchBindingException e) {}
+
+ ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
+ store.removeServiceBinding(new1);
+ store.removeServiceBinding(B, A);
+ }
+
+ public void testDefaultDefaults() throws Exception
+ {
+ PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+
+ String[] names = {A, B, C};
+
+ for (String name :names)
+ {
+ assertNull(store.getDefaultHostName(name));
+ assertNull(store.getDefaultBindAddress(name));
+ assertEquals(0, store.getDefaultPortOffset(name));
+ }
+ }
+
+ public void testDefaults() throws Exception
+ {
+ Set<ServiceBinding> set = new HashSet<ServiceBinding>();
+ set.addAll(Arrays.asList(AA, AB, Anull));
+
+ ServiceBindingSet sbs = new ServiceBindingSet(set, 10, null);
+ Map<String, ServiceBindingSet> map = new HashMap<String, ServiceBindingSet>();
+ map.put(A, sbs);
+
+ sbs = new ServiceBindingSet(set, 20, "localhost");
+ map.put(B, sbs);
+
+ sbs = new ServiceBindingSet(set, 30, "192.168.0.10");
+ map.put(C, sbs);
+
+ PojoServiceBindingStore store = new PojoServiceBindingStore(map);
+
+ assertNull(store.getDefaultHostName(A));
+ assertNull(store.getDefaultBindAddress(A));
+ assertEquals(10, store.getDefaultPortOffset(A));
+
+ assertEquals("localhost", store.getDefaultHostName(B));
+ assertEquals(InetAddress.getByName("localhost"), store.getDefaultBindAddress(B));
+ assertEquals(20, store.getDefaultPortOffset(B));
+
+ assertEquals("192.168.0.10", store.getDefaultHostName(C));
+ assertEquals(InetAddress.getByName("192.168.0.10"), store.getDefaultBindAddress(C));
+ assertEquals(30, store.getDefaultPortOffset(C));
+ }
+
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,415 +1,415 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.File;
-import java.net.InetAddress;
-import java.net.URL;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingManager;
-import org.w3c.dom.Element;
-
-/**
- * Tests of ServiceBindingManager.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1 $
- */
-public class ServiceBindingManagerUnitTestCase extends ServiceBindingTestBase
-{
- private static final String SERVER = "server";
- private static final String INPUT = "${host}";
-
- private ServiceBindingManager testee;
- private ServiceBinding noNameBinding;
- private MockServiceBindingStore mockStore;
- private InetAddress address;
-
- /**
- * Create a new ServiceBindingManagerUnitTestCase.
- *
- * @param arg0
- */
- public ServiceBindingManagerUnitTestCase(String arg0)
- {
- super(arg0);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- mockStore = new MockServiceBindingStore(binding, SERVER);
- testee = new ServiceBindingManager(SERVER, mockStore);
- noNameBinding = new ServiceBinding(SVC_NAME, null, HOST, PORT);
- address = InetAddress.getByName(HOST);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String)}.
- * @throws Exception
- */
- public void testGetIntBindingString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- assertEquals(PORT, testee.getIntBinding(SVC_NAME));
- }
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetIntBindingStringString() throws Exception
- {
- assertEquals(PORT, testee.getIntBinding(SVC_NAME, BINDING_NAME));
- }
-
- public void testGetIntBindingViaGeneric() throws Exception
- {
- Integer result = new Integer(5);
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- binding.setServiceBindingValueSource(source);
- assertEquals(5, testee.getIntBinding(SVC_NAME, BINDING_NAME));
- Object[] params = source.getParams();
- assertNull(params);
- }
-
- public void testGetIntBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
- }
-
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String)}.
- */
- public void testGetInetAddressBindingString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- assertEquals(address, testee.getInetAddressBinding(SVC_NAME));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetInetAddressBindingStringString() throws Exception
- {
- assertEquals(address, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
- }
-
- public void testGetInetAddressBindingViaGeneric() throws Exception
- {
- InetAddress result = InetAddress.getByName("localhost");
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- binding.setServiceBindingValueSource(source);
- assertEquals(result, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
- Object[] params = source.getParams();
- assertNull(params);
- }
-
- public void testGetInetAddressBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- assertEquals(binding.getBindAddress(), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(null), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetStringBindingStringString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- assertEquals(HOST, testee.getStringBinding(SVC_NAME, INPUT));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String, java.lang.String)}.
- */
- public void testGetStringBindingStringStringString() throws Exception
- {
- assertEquals(HOST, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
- }
-
- public void testGetStringBindingViaGeneric() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- binding.setServiceBindingValueSource(source);
- assertEquals(SVC_NAME, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- public void testGetStringBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- assertEquals(binding.getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, binding.getHostName(), binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(null).getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, null, binding.getPort()));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, org.w3c.dom.Element)}.
- */
- public void testGetElementBindingStringElement() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementBinding(SVC_NAME, input);
- validateOutputElement(output);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, java.lang.String, org.w3c.dom.Element)}.
- */
- public void testGetElementBindingStringStringElement() throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
- validateOutputElement(output);
- }
-
- public void testGetElementBindingViaGeneric() throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element result = (Element) editor.getValue();
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- binding.setServiceBindingValueSource(source);
- assertEquals(result, testee.getElementBinding(SVC_NAME, BINDING_NAME, result));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(result, params[0]);
- }
-
- public void testGetElementBindingViaXSLT() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(getXSLTConfig());
-
- Element input = getDocumentElementFromClasspath(XSL_INPUT);
- Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
- validateXSLTOutputElement(output);
- }
-
- public void testGetElementBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
- validateOutputElement(output);
- mockStore.setBinding(null);
- output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
-
- assertNotNull(output);
- assertEquals("localhost", output.getAttribute("host"));
- assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.net.URL)}.
- */
- public void testGetURLBindingStringURL() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLBinding(SVC_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.lang.String, java.net.URL)}.
- */
- public void testGetURLBindingStringStringURL() throws Exception
- {
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetURLBindingViaGeneric() throws Exception
- {
- URL result = new File(getFullyQualifiedResourceName("input.xml")).toURL();
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- binding.setServiceBindingValueSource(source);
- assertEquals(result, testee.getURLBinding(SVC_NAME, BINDING_NAME, result));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(result, params[0]);
- }
-
- public void testGetURLBindingViaXSLT() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(getXSLTConfig());
-
- URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
- URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetURLBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
-
- mockStore.setBinding(null);
- output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
-
- assertNotNull(output);
- element = getDocumentElement(output);
- assertEquals("localhost", element.getAttribute("host"));
- assertEquals(String.valueOf(PORT), element.getFirstChild().getNodeValue());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetResourceBindingStringString() throws Exception
- {
- String input = getFullyQualifiedResourceName("input.xml");
- String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String, java.lang.String)}.
- */
- public void testGetResourceBindingStringStringString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- String input = getFullyQualifiedResourceName("input.xml");
- String output = testee.getResourceBinding(SVC_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetResourceBindingViaGeneric() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- binding.setServiceBindingValueSource(source);
- assertEquals(SVC_NAME, testee.getResourceBinding(SVC_NAME, BINDING_NAME, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- public void testGetResourceBindingViaXSLT() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(getXSLTConfig());
-
- String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, XSL_INPUT);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetResourceBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- String input = getFullyQualifiedResourceName("input.xml");
- String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
-
- mockStore.setBinding(null);
- output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
-
- assertNotNull(output);
- element = getDocumentElement(output);
- assertEquals("localhost", element.getAttribute("host"));
- assertEquals(String.valueOf(PORT), element.getFirstChild().getNodeValue());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.Object[])}.
- */
- public void testGetGenericBindingStringObjectArray() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- noNameBinding.setServiceBindingValueSource(source);
- assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, null, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.String, java.lang.Object[])}.
- */
- public void testGetGenericBindingStringStringObjectArray() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- binding.setServiceBindingValueSource(source);
- assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, BINDING_NAME, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- public void testGetGenericBindingNoValueSource() throws Exception
- {
- try
- {
- Object[] params = null;
- testee.getGenericBinding(SVC_NAME, BINDING_NAME, params);
- fail("should not succeed without value source");
- }
- catch (IllegalStateException good) {}
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.File;
+import java.net.InetAddress;
+import java.net.URL;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingManager;
+import org.w3c.dom.Element;
+
+/**
+ * Tests of ServiceBindingManager.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class ServiceBindingManagerUnitTestCase extends ServiceBindingTestBase
+{
+ private static final String SERVER = "server";
+ private static final String INPUT = "${host}";
+
+ private ServiceBindingManager testee;
+ private ServiceBinding noNameBinding;
+ private MockServiceBindingStore mockStore;
+ private InetAddress address;
+
+ /**
+ * Create a new ServiceBindingManagerUnitTestCase.
+ *
+ * @param arg0
+ */
+ public ServiceBindingManagerUnitTestCase(String arg0)
+ {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ mockStore = new MockServiceBindingStore(binding, SERVER);
+ testee = new ServiceBindingManager(SERVER, mockStore);
+ noNameBinding = new ServiceBinding(SVC_NAME, null, HOST, PORT);
+ address = InetAddress.getByName(HOST);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String)}.
+ * @throws Exception
+ */
+ public void testGetIntBindingString() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ assertEquals(PORT, testee.getIntBinding(SVC_NAME));
+ }
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String, java.lang.String)}.
+ */
+ public void testGetIntBindingStringString() throws Exception
+ {
+ assertEquals(PORT, testee.getIntBinding(SVC_NAME, BINDING_NAME));
+ }
+
+ public void testGetIntBindingViaGeneric() throws Exception
+ {
+ Integer result = new Integer(5);
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(5, testee.getIntBinding(SVC_NAME, BINDING_NAME));
+ Object[] params = source.getParams();
+ assertNull(params);
+ }
+
+ public void testGetIntBindingNoBinding() throws Exception
+ {
+ mockStore.setBinding(null);
+ assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
+ mockStore.setBinding(null);
+ assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
+ }
+
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String)}.
+ */
+ public void testGetInetAddressBindingString() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ assertEquals(address, testee.getInetAddressBinding(SVC_NAME));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String, java.lang.String)}.
+ */
+ public void testGetInetAddressBindingStringString() throws Exception
+ {
+ assertEquals(address, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
+ }
+
+ public void testGetInetAddressBindingViaGeneric() throws Exception
+ {
+ InetAddress result = InetAddress.getByName("localhost");
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(result, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
+ Object[] params = source.getParams();
+ assertNull(params);
+ }
+
+ public void testGetInetAddressBindingNoBinding() throws Exception
+ {
+ mockStore.setBinding(null);
+ assertEquals(binding.getBindAddress(), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
+ mockStore.setBinding(null);
+ assertEquals(InetAddress.getByName(null), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String)}.
+ */
+ public void testGetStringBindingStringString() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ assertEquals(HOST, testee.getStringBinding(SVC_NAME, INPUT));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String, java.lang.String)}.
+ */
+ public void testGetStringBindingStringStringString() throws Exception
+ {
+ assertEquals(HOST, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
+ }
+
+ public void testGetStringBindingViaGeneric() throws Exception
+ {
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(SVC_NAME, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
+ Object[] params = source.getParams();
+ assertNotNull(params);
+ assertEquals(1, params.length);
+ assertEquals(INPUT, params[0]);
+ }
+
+ public void testGetStringBindingNoBinding() throws Exception
+ {
+ mockStore.setBinding(null);
+ assertEquals(binding.getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, binding.getHostName(), binding.getPort()));
+ mockStore.setBinding(null);
+ assertEquals(InetAddress.getByName(null).getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, null, binding.getPort()));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, org.w3c.dom.Element)}.
+ */
+ public void testGetElementBindingStringElement() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ editor.setAsText(ELEMENT_INPUT);
+ Element input = (Element) editor.getValue();
+ Element output = testee.getElementBinding(SVC_NAME, input);
+ validateOutputElement(output);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, java.lang.String, org.w3c.dom.Element)}.
+ */
+ public void testGetElementBindingStringStringElement() throws Exception
+ {
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ editor.setAsText(ELEMENT_INPUT);
+ Element input = (Element) editor.getValue();
+ Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
+ validateOutputElement(output);
+ }
+
+ public void testGetElementBindingViaGeneric() throws Exception
+ {
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ editor.setAsText(ELEMENT_INPUT);
+ Element result = (Element) editor.getValue();
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(result, testee.getElementBinding(SVC_NAME, BINDING_NAME, result));
+ Object[] params = source.getParams();
+ assertNotNull(params);
+ assertEquals(1, params.length);
+ assertEquals(result, params[0]);
+ }
+
+ public void testGetElementBindingViaXSLT() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(getXSLTConfig());
+
+ Element input = getDocumentElementFromClasspath(XSL_INPUT);
+ Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
+ validateXSLTOutputElement(output);
+ }
+
+ public void testGetElementBindingNoBinding() throws Exception
+ {
+ mockStore.setBinding(null);
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ editor.setAsText(ELEMENT_INPUT);
+ Element input = (Element) editor.getValue();
+ Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
+ validateOutputElement(output);
+ mockStore.setBinding(null);
+ output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
+
+ assertNotNull(output);
+ assertEquals("localhost", output.getAttribute("host"));
+ assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.net.URL)}.
+ */
+ public void testGetURLBindingStringURL() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ String resource = getFullyQualifiedResourceName("input.xml");
+ URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+ URL output = testee.getURLBinding(SVC_NAME, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.lang.String, java.net.URL)}.
+ */
+ public void testGetURLBindingStringStringURL() throws Exception
+ {
+ String resource = getFullyQualifiedResourceName("input.xml");
+ URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+ URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ public void testGetURLBindingViaGeneric() throws Exception
+ {
+ URL result = new File(getFullyQualifiedResourceName("input.xml")).toURL();
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(result, testee.getURLBinding(SVC_NAME, BINDING_NAME, result));
+ Object[] params = source.getParams();
+ assertNotNull(params);
+ assertEquals(1, params.length);
+ assertEquals(result, params[0]);
+ }
+
+ public void testGetURLBindingViaXSLT() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(getXSLTConfig());
+
+ URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
+ URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateXSLTOutputElement(element);
+ }
+
+ public void testGetURLBindingNoBinding() throws Exception
+ {
+ mockStore.setBinding(null);
+ String resource = getFullyQualifiedResourceName("input.xml");
+ URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+ URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+
+ mockStore.setBinding(null);
+ output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
+
+ assertNotNull(output);
+ element = getDocumentElement(output);
+ assertEquals("localhost", element.getAttribute("host"));
+ assertEquals(String.valueOf(PORT), element.getFirstChild().getNodeValue());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String)}.
+ */
+ public void testGetResourceBindingStringString() throws Exception
+ {
+ String input = getFullyQualifiedResourceName("input.xml");
+ String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String, java.lang.String)}.
+ */
+ public void testGetResourceBindingStringStringString() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ String input = getFullyQualifiedResourceName("input.xml");
+ String output = testee.getResourceBinding(SVC_NAME, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ public void testGetResourceBindingViaGeneric() throws Exception
+ {
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(SVC_NAME, testee.getResourceBinding(SVC_NAME, BINDING_NAME, INPUT));
+ Object[] params = source.getParams();
+ assertNotNull(params);
+ assertEquals(1, params.length);
+ assertEquals(INPUT, params[0]);
+ }
+
+ public void testGetResourceBindingViaXSLT() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(getXSLTConfig());
+
+ String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, XSL_INPUT);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateXSLTOutputElement(element);
+ }
+
+ public void testGetResourceBindingNoBinding() throws Exception
+ {
+ mockStore.setBinding(null);
+ String input = getFullyQualifiedResourceName("input.xml");
+ String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+
+ mockStore.setBinding(null);
+ output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
+
+ assertNotNull(output);
+ element = getDocumentElement(output);
+ assertEquals("localhost", element.getAttribute("host"));
+ assertEquals(String.valueOf(PORT), element.getFirstChild().getNodeValue());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.Object[])}.
+ */
+ public void testGetGenericBindingStringObjectArray() throws Exception
+ {
+ mockStore.setBinding(noNameBinding);
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+ noNameBinding.setServiceBindingValueSource(source);
+ assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, null, INPUT));
+ Object[] params = source.getParams();
+ assertNotNull(params);
+ assertEquals(1, params.length);
+ assertEquals(INPUT, params[0]);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.String, java.lang.Object[])}.
+ */
+ public void testGetGenericBindingStringStringObjectArray() throws Exception
+ {
+ MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+ binding.setServiceBindingValueSource(source);
+ assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, BINDING_NAME, INPUT));
+ Object[] params = source.getParams();
+ assertNotNull(params);
+ assertEquals(1, params.length);
+ assertEquals(INPUT, params[0]);
+ }
+
+ public void testGetGenericBindingNoValueSource() throws Exception
+ {
+ try
+ {
+ Object[] params = null;
+ testee.getGenericBinding(SVC_NAME, BINDING_NAME, params);
+ fail("should not succeed without value source");
+ }
+ catch (IllegalStateException good) {}
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,154 +1,154 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.ServiceBindingSet;
-
-/**
- * A ServiceBindingSetUnitTestCase.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class ServiceBindingSetUnitTestCase extends TestCase
-{
- private static final String A = "A";
- private static final String B = "B";
-
- private static ServiceBinding AA;
- private static ServiceBinding AB;
- private static ServiceBinding Anull;
-
- private Set<ServiceBinding> bindings = new HashSet<ServiceBinding>();
-
- /**
- * Create a new ServiceBindingSetUnitTestCase.
- *
- * @param name
- */
- public ServiceBindingSetUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- AA = new ServiceBinding(A, A, "localhost", 1);
- AB = new ServiceBinding(A, B, "localhost", 1);
- Anull = new ServiceBinding(A, null, "localhost", 1);
-
- bindings.addAll(Arrays.asList(AA, AB, Anull));
- }
-
- public void testBasicConstructor() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(bindings);
- for (ServiceBinding binding : set)
- {
- assertEquals(1, binding.getPort());
- assertTrue(bindings.remove(binding));
- }
-
- assertEquals(0, bindings.size());
-
- assertNull(set.getDefaultHostName());
- assertNull(set.getDefaultBindAddress());
- assertEquals(0, set.getPortOffset());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int)}.
- * @throws UnknownHostException
- */
- public void testOffsetConstructor() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(bindings, 5);
- for (ServiceBinding binding : set)
- {
- assertEquals(6, binding.getPort());
- assertTrue(bindings.remove(binding));
- }
-
- assertEquals(0, bindings.size());
-
- assertNull(set.getDefaultHostName());
- assertNull(set.getDefaultBindAddress());
- assertEquals(5, set.getPortOffset());
- }
-
- public void testOffsetConstructorWithDefaultHost() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(bindings, 5, "192.168.0.10");
- for (ServiceBinding binding : set)
- {
- assertEquals(6, binding.getPort());
- assertTrue(bindings.remove(binding));
- }
-
- assertEquals(0, bindings.size());
-
- assertEquals("192.168.0.10", set.getDefaultHostName());
- assertEquals(InetAddress.getByName("192.168.0.10"), set.getDefaultBindAddress());
- assertEquals(5, set.getPortOffset());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int, java.util.Set)}.
- * @throws UnknownHostException
- */
- public void testOverrideConstructor() throws UnknownHostException
- {
- ServiceBinding bb = new ServiceBinding(B, B, "localhost", 1);
- Set<ServiceBinding> overrides = new HashSet<ServiceBinding>();
- overrides.add(bb);
- overrides.add(AA);
-
- ServiceBindingSet set = new ServiceBindingSet(bindings, 10, overrides, "192.168.0.10");
- for (ServiceBinding binding : set)
- {
- boolean override = overrides.remove(binding);
- assertEquals(override ? 1 : 11, binding.getPort());
- assertTrue(bindings.remove(binding) || override);
-
- }
-
- assertEquals(0, overrides.size());
- assertEquals(0, bindings.size());
-
- assertEquals("192.168.0.10", set.getDefaultHostName());
- assertEquals(InetAddress.getByName("192.168.0.10"), set.getDefaultBindAddress());
- assertEquals(10, set.getPortOffset());
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.ServiceBindingSet;
+
+/**
+ * A ServiceBindingSetUnitTestCase.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class ServiceBindingSetUnitTestCase extends TestCase
+{
+ private static final String A = "A";
+ private static final String B = "B";
+
+ private static ServiceBinding AA;
+ private static ServiceBinding AB;
+ private static ServiceBinding Anull;
+
+ private Set<ServiceBinding> bindings = new HashSet<ServiceBinding>();
+
+ /**
+ * Create a new ServiceBindingSetUnitTestCase.
+ *
+ * @param name
+ */
+ public ServiceBindingSetUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ AA = new ServiceBinding(A, A, "localhost", 1);
+ AB = new ServiceBinding(A, B, "localhost", 1);
+ Anull = new ServiceBinding(A, null, "localhost", 1);
+
+ bindings.addAll(Arrays.asList(AA, AB, Anull));
+ }
+
+ public void testBasicConstructor() throws UnknownHostException
+ {
+ ServiceBindingSet set = new ServiceBindingSet(bindings);
+ for (ServiceBinding binding : set)
+ {
+ assertEquals(1, binding.getPort());
+ assertTrue(bindings.remove(binding));
+ }
+
+ assertEquals(0, bindings.size());
+
+ assertNull(set.getDefaultHostName());
+ assertNull(set.getDefaultBindAddress());
+ assertEquals(0, set.getPortOffset());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int)}.
+ * @throws UnknownHostException
+ */
+ public void testOffsetConstructor() throws UnknownHostException
+ {
+ ServiceBindingSet set = new ServiceBindingSet(bindings, 5);
+ for (ServiceBinding binding : set)
+ {
+ assertEquals(6, binding.getPort());
+ assertTrue(bindings.remove(binding));
+ }
+
+ assertEquals(0, bindings.size());
+
+ assertNull(set.getDefaultHostName());
+ assertNull(set.getDefaultBindAddress());
+ assertEquals(5, set.getPortOffset());
+ }
+
+ public void testOffsetConstructorWithDefaultHost() throws UnknownHostException
+ {
+ ServiceBindingSet set = new ServiceBindingSet(bindings, 5, "192.168.0.10");
+ for (ServiceBinding binding : set)
+ {
+ assertEquals(6, binding.getPort());
+ assertTrue(bindings.remove(binding));
+ }
+
+ assertEquals(0, bindings.size());
+
+ assertEquals("192.168.0.10", set.getDefaultHostName());
+ assertEquals(InetAddress.getByName("192.168.0.10"), set.getDefaultBindAddress());
+ assertEquals(5, set.getPortOffset());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int, java.util.Set)}.
+ * @throws UnknownHostException
+ */
+ public void testOverrideConstructor() throws UnknownHostException
+ {
+ ServiceBinding bb = new ServiceBinding(B, B, "localhost", 1);
+ Set<ServiceBinding> overrides = new HashSet<ServiceBinding>();
+ overrides.add(bb);
+ overrides.add(AA);
+
+ ServiceBindingSet set = new ServiceBindingSet(bindings, 10, overrides, "192.168.0.10");
+ for (ServiceBinding binding : set)
+ {
+ boolean override = overrides.remove(binding);
+ assertEquals(override ? 1 : 11, binding.getPort());
+ assertTrue(bindings.remove(binding) || override);
+
+ }
+
+ assertEquals(0, overrides.size());
+ assertEquals(0, bindings.size());
+
+ assertEquals("192.168.0.10", set.getDefaultHostName());
+ assertEquals(InetAddress.getByName("192.168.0.10"), set.getDefaultBindAddress());
+ assertEquals(10, set.getPortOffset());
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,184 +1,184 @@
-package org.jboss.test.services.binding.test;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.util.propertyeditor.ElementEditor;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * Base class for service binding manager related test classes.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public abstract class ServiceBindingTestBase extends TestCase
-{
- protected static final String SVC_NAME = "SVC";
- protected static final String BINDING_NAME = "BIND";
- protected static final String HOST = "192.168.0.10";
- protected static final int PORT = 999;
- protected static final String HOST_MARKER = "${host}";
- protected static final String PORT_MARKER = "${port}";
- protected static final String ELEMENT_INPUT = "<element host=\"" + HOST_MARKER + "\">" + PORT_MARKER + "</element>";
-
- protected static final String OTHER_PARAM = "other";
- protected static final String OTHER_VALUE = "ABC";
- protected static final String XSL_INPUT = getFullyQualifiedResourceName("xslt_input.xml");
-
- protected ServiceBinding binding;
-
- private PropertyEditor existingElementEditor;
- private String serverTempDir;
-
- public ServiceBindingTestBase()
- {
- super();
- }
-
- public ServiceBindingTestBase(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- existingElementEditor = PropertyEditorManager.findEditor(Element.class);
- if (existingElementEditor == null)
- PropertyEditorManager.registerEditor(Element.class, ElementEditor.class);
-
- serverTempDir = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
- if (serverTempDir == null)
- System.setProperty(ServerConfig.SERVER_TEMP_DIR, System.getProperty("java.io.tmpdir"));
-
- binding = new ServiceBinding(SVC_NAME, BINDING_NAME, HOST, PORT);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- if (existingElementEditor == null)
- PropertyEditorManager.registerEditor(Element.class, null);
- if (serverTempDir == null)
- System.clearProperty(ServerConfig.SERVER_TEMP_DIR);
-
- super.tearDown();
- }
-
- public static String getFullyQualifiedResourceName(String unqualified)
- {
- String base = ServiceBindingTestBase.class.getPackage().getName();
- base = base.replace('.', '/');
- return base + "/" + unqualified;
- }
-
- protected void validateOutputElement(Element output)
- {
- assertNotNull(output);
- assertEquals(HOST, output.getAttribute("host"));
- assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
- }
-
- protected void validateXSLTOutputElement(Element output)
- {
- assertNotNull(output);
- NodeList children = output.getElementsByTagName("attribute");
- assertEquals(3, children.getLength());
- for (int i = 0; i < children.getLength(); i++)
- {
- Element e = (Element) children.item(i);
- String name = e.getAttribute("name");
- if ("host".equals(name))
- assertEquals(HOST, e.getFirstChild().getNodeValue());
- else if ("port".equals(name))
- assertEquals(String.valueOf(PORT), e.getFirstChild().getNodeValue());
- else if ("other".equals(name))
- assertEquals(OTHER_VALUE, e.getFirstChild().getNodeValue());
- else
- fail("Unknown attribute name " + name);
- }
- }
-
- public static Element getDocumentElement(String filename) throws Exception
- {
- File f = new File(filename);
- Assert.assertTrue(f.exists());
- Assert.assertFalse(f.isDirectory());
- InputStreamReader reader = new InputStreamReader(new FileInputStream(f));
- return getDocumentElement(reader);
- }
-
- public static Element getDocumentElementFromClasspath(String resourcename) throws Exception
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStreamReader reader = new InputStreamReader(cl.getResourceAsStream(resourcename));
- return getDocumentElement(reader);
- }
-
- public static Element getDocumentElement(URL url) throws Exception
- {
- URLConnection conn = url.openConnection();
- conn.connect();
- InputStreamReader reader = new InputStreamReader(url.openStream());
- return getDocumentElement(reader);
- }
-
- public static Element getDocumentElement(Reader reader) throws Exception
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder parser = factory.newDocumentBuilder();
- try
- {
-
- InputSource is = new InputSource(reader);
-// is.setSystemId(url.toString());
- parser.setEntityResolver(new JBossEntityResolver());
-
- Document document = parser.parse(is);
- return document.getDocumentElement();
- }
- finally
- {
- reader.close();
- }
-
- }
-
- public static XSLTServiceBindingValueSourceConfig getXSLTConfig() throws Exception
- {
- Element element = getDocumentElementFromClasspath(getFullyQualifiedResourceName("xslt.xml"));
- String xslt = element.getFirstChild().getNodeValue();
-
- Map<String, String> addlParams = new HashMap<String, String>();
- addlParams.put(OTHER_PARAM, OTHER_VALUE);
-
- return new XSLTServiceBindingValueSourceConfig(xslt, addlParams);
- }
-
-
-
+package org.jboss.test.services.binding.test;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.util.propertyeditor.ElementEditor;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Base class for service binding manager related test classes.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public abstract class ServiceBindingTestBase extends TestCase
+{
+ protected static final String SVC_NAME = "SVC";
+ protected static final String BINDING_NAME = "BIND";
+ protected static final String HOST = "192.168.0.10";
+ protected static final int PORT = 999;
+ protected static final String HOST_MARKER = "${host}";
+ protected static final String PORT_MARKER = "${port}";
+ protected static final String ELEMENT_INPUT = "<element host=\"" + HOST_MARKER + "\">" + PORT_MARKER + "</element>";
+
+ protected static final String OTHER_PARAM = "other";
+ protected static final String OTHER_VALUE = "ABC";
+ protected static final String XSL_INPUT = getFullyQualifiedResourceName("xslt_input.xml");
+
+ protected ServiceBinding binding;
+
+ private PropertyEditor existingElementEditor;
+ private String serverTempDir;
+
+ public ServiceBindingTestBase()
+ {
+ super();
+ }
+
+ public ServiceBindingTestBase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ existingElementEditor = PropertyEditorManager.findEditor(Element.class);
+ if (existingElementEditor == null)
+ PropertyEditorManager.registerEditor(Element.class, ElementEditor.class);
+
+ serverTempDir = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
+ if (serverTempDir == null)
+ System.setProperty(ServerConfig.SERVER_TEMP_DIR, System.getProperty("java.io.tmpdir"));
+
+ binding = new ServiceBinding(SVC_NAME, BINDING_NAME, HOST, PORT);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (existingElementEditor == null)
+ PropertyEditorManager.registerEditor(Element.class, null);
+ if (serverTempDir == null)
+ System.clearProperty(ServerConfig.SERVER_TEMP_DIR);
+
+ super.tearDown();
+ }
+
+ public static String getFullyQualifiedResourceName(String unqualified)
+ {
+ String base = ServiceBindingTestBase.class.getPackage().getName();
+ base = base.replace('.', '/');
+ return base + "/" + unqualified;
+ }
+
+ protected void validateOutputElement(Element output)
+ {
+ assertNotNull(output);
+ assertEquals(HOST, output.getAttribute("host"));
+ assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
+ }
+
+ protected void validateXSLTOutputElement(Element output)
+ {
+ assertNotNull(output);
+ NodeList children = output.getElementsByTagName("attribute");
+ assertEquals(3, children.getLength());
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Element e = (Element) children.item(i);
+ String name = e.getAttribute("name");
+ if ("host".equals(name))
+ assertEquals(HOST, e.getFirstChild().getNodeValue());
+ else if ("port".equals(name))
+ assertEquals(String.valueOf(PORT), e.getFirstChild().getNodeValue());
+ else if ("other".equals(name))
+ assertEquals(OTHER_VALUE, e.getFirstChild().getNodeValue());
+ else
+ fail("Unknown attribute name " + name);
+ }
+ }
+
+ public static Element getDocumentElement(String filename) throws Exception
+ {
+ File f = new File(filename);
+ Assert.assertTrue(f.exists());
+ Assert.assertFalse(f.isDirectory());
+ InputStreamReader reader = new InputStreamReader(new FileInputStream(f));
+ return getDocumentElement(reader);
+ }
+
+ public static Element getDocumentElementFromClasspath(String resourcename) throws Exception
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStreamReader reader = new InputStreamReader(cl.getResourceAsStream(resourcename));
+ return getDocumentElement(reader);
+ }
+
+ public static Element getDocumentElement(URL url) throws Exception
+ {
+ URLConnection conn = url.openConnection();
+ conn.connect();
+ InputStreamReader reader = new InputStreamReader(url.openStream());
+ return getDocumentElement(reader);
+ }
+
+ public static Element getDocumentElement(Reader reader) throws Exception
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ try
+ {
+
+ InputSource is = new InputSource(reader);
+// is.setSystemId(url.toString());
+ parser.setEntityResolver(new JBossEntityResolver());
+
+ Document document = parser.parse(is);
+ return document.getDocumentElement();
+ }
+ finally
+ {
+ reader.close();
+ }
+
+ }
+
+ public static XSLTServiceBindingValueSourceConfig getXSLTConfig() throws Exception
+ {
+ Element element = getDocumentElementFromClasspath(getFullyQualifiedResourceName("xslt.xml"));
+ String xslt = element.getFirstChild().getNodeValue();
+
+ Map<String, String> addlParams = new HashMap<String, String>();
+ addlParams.put(OTHER_PARAM, OTHER_VALUE);
+
+ return new XSLTServiceBindingValueSourceConfig(xslt, addlParams);
+ }
+
+
+
}
\ No newline at end of file
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,147 +1,147 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-
-import junit.framework.TestCase;
-
-/**
- * Tests of ServiceBinding.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class ServiceBindingUnitTestCase extends TestCase
-{
-
- /**
- * Create a new ServiceBindingUnitTestCase.
- *
- * @param name
- */
- public ServiceBindingUnitTestCase(String name)
- {
- super(name);
- }
-
- public void testNullServiceName() throws Exception
- {
- try
- {
- new ServiceBinding(null, 1);
- fail("null serviceName should fail");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#getServiceBindingValueSource()}.
- */
- public void testServiceBindingValueSourceClassName() throws Exception
- {
- ServiceBinding binding = new ServiceBinding("test", 1);
- String className = XSLTServiceBindingValueSourceImpl.class.getName();
- binding.setServiceBindingValueSourceClassName(className);
- assertEquals(className, binding.getServiceBindingValueSourceClassName());
- assertTrue(binding.getServiceBindingValueSource() instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#getOffsetBinding(int)}.
- */
- public void testGetOffsetBinding() throws Exception
- {
- ServiceBinding binding = new ServiceBinding("svc", "binding", "192.168.0.2", 1);
- String className = XSLTServiceBindingValueSourceImpl.class.getName();
- binding.setServiceBindingValueSourceClassName(className);
-
- ServiceBinding binding2 = binding.getOffsetBinding(10);
- assertEquals(binding.getServiceName(), binding2.getServiceName());
- assertEquals(binding.getBindingName(), binding2.getBindingName());
- assertEquals(binding.getHostName(), binding2.getHostName());
- assertEquals(binding.getBindAddress(), binding2.getBindAddress());
-
- assertEquals(1, binding.getPort());
- assertEquals(11, binding2.getPort());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#equals(java.lang.Object)}.
- */
- public void testEquals() throws Exception
- {
- ServiceBinding bindingAA0 = new ServiceBinding("A", "A", "192.168.0.2", 1);
- ServiceBinding bindingAA1 = new ServiceBinding("A", "A", "192.168.0.2", 2);
- ServiceBinding bindingAA2 = new ServiceBinding("A", "A", "192.168.0.1", 1);
- ServiceBinding bindingAB = new ServiceBinding("A", "B", "192.168.0.2", 1);
- ServiceBinding bindingBA = new ServiceBinding("B", "A", "192.168.0.2", 1);
- ServiceBinding bindingAnull = new ServiceBinding("A", null, "192.168.0.2", 1);
- ServiceBinding bindingBnull = new ServiceBinding("B", null, "192.168.0.2", 1);
- ServiceBinding bindingBnull1 = new ServiceBinding("B", null, "192.168.0.2", 2);
-
- assertEquals(bindingAA0, bindingAA1);
- assertEquals(bindingAA0, bindingAA2);
- assertFalse(bindingAA0.equals(bindingAB));
- assertFalse(bindingAA0.equals(bindingBA));
- assertFalse(bindingAB.equals(bindingBA));
- assertFalse(bindingAA0.equals(bindingAnull));
- assertFalse(bindingBA.equals(bindingBnull));
- assertFalse(bindingAnull.equals(bindingBnull));
- assertEquals(bindingBnull, bindingBnull1);
-
- assertFalse(bindingAA0.equals(new Object()));
-
- assertFalse(bindingAA0.equals(null));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#hashCode()}.
- */
- public void testHashCode() throws Exception
- {
- ServiceBinding bindingAA0 = new ServiceBinding("A", "A", "192.168.0.2", 1);
- ServiceBinding bindingAA1 = new ServiceBinding("A", "A", "192.168.0.2", 2);
- ServiceBinding bindingAA2 = new ServiceBinding("A", "A", "192.168.0.1", 1);
- ServiceBinding bindingAB = new ServiceBinding("A", "B", "192.168.0.2", 1);
- ServiceBinding bindingBA = new ServiceBinding("B", "A", "192.168.0.2", 1);
- ServiceBinding bindingAnull = new ServiceBinding("A", null, "192.168.0.2", 1);
- ServiceBinding bindingBnull = new ServiceBinding("B", null, "192.168.0.2", 1);
- ServiceBinding bindingBnull1 = new ServiceBinding("B", null, "192.168.0.2", 2);
-
- assertEquals(bindingAA0.hashCode(), bindingAA1.hashCode());
- assertEquals(bindingAA0.hashCode(), bindingAA2.hashCode());
- assertFalse(bindingAA0.hashCode() == bindingAB.hashCode());
- assertFalse(bindingAA0.hashCode() == bindingBA.hashCode());
-
- // A quirk of the values means these have same hashcode
- assertEquals(bindingAB.hashCode(), bindingBA.hashCode());
-
- assertFalse(bindingAA0.hashCode() == bindingAnull.hashCode());
- assertFalse(bindingBA.hashCode() == bindingBnull.hashCode());
- assertFalse(bindingAnull.hashCode() == bindingBnull.hashCode());
- assertEquals(bindingBnull.hashCode(), bindingBnull1.hashCode());
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests of ServiceBinding.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class ServiceBindingUnitTestCase extends TestCase
+{
+
+ /**
+ * Create a new ServiceBindingUnitTestCase.
+ *
+ * @param name
+ */
+ public ServiceBindingUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNullServiceName() throws Exception
+ {
+ try
+ {
+ new ServiceBinding(null, 1);
+ fail("null serviceName should fail");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBinding#getServiceBindingValueSource()}.
+ */
+ public void testServiceBindingValueSourceClassName() throws Exception
+ {
+ ServiceBinding binding = new ServiceBinding("test", 1);
+ String className = XSLTServiceBindingValueSourceImpl.class.getName();
+ binding.setServiceBindingValueSourceClassName(className);
+ assertEquals(className, binding.getServiceBindingValueSourceClassName());
+ assertTrue(binding.getServiceBindingValueSource() instanceof XSLTServiceBindingValueSourceImpl);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBinding#getOffsetBinding(int)}.
+ */
+ public void testGetOffsetBinding() throws Exception
+ {
+ ServiceBinding binding = new ServiceBinding("svc", "binding", "192.168.0.2", 1);
+ String className = XSLTServiceBindingValueSourceImpl.class.getName();
+ binding.setServiceBindingValueSourceClassName(className);
+
+ ServiceBinding binding2 = binding.getOffsetBinding(10);
+ assertEquals(binding.getServiceName(), binding2.getServiceName());
+ assertEquals(binding.getBindingName(), binding2.getBindingName());
+ assertEquals(binding.getHostName(), binding2.getHostName());
+ assertEquals(binding.getBindAddress(), binding2.getBindAddress());
+
+ assertEquals(1, binding.getPort());
+ assertEquals(11, binding2.getPort());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBinding#equals(java.lang.Object)}.
+ */
+ public void testEquals() throws Exception
+ {
+ ServiceBinding bindingAA0 = new ServiceBinding("A", "A", "192.168.0.2", 1);
+ ServiceBinding bindingAA1 = new ServiceBinding("A", "A", "192.168.0.2", 2);
+ ServiceBinding bindingAA2 = new ServiceBinding("A", "A", "192.168.0.1", 1);
+ ServiceBinding bindingAB = new ServiceBinding("A", "B", "192.168.0.2", 1);
+ ServiceBinding bindingBA = new ServiceBinding("B", "A", "192.168.0.2", 1);
+ ServiceBinding bindingAnull = new ServiceBinding("A", null, "192.168.0.2", 1);
+ ServiceBinding bindingBnull = new ServiceBinding("B", null, "192.168.0.2", 1);
+ ServiceBinding bindingBnull1 = new ServiceBinding("B", null, "192.168.0.2", 2);
+
+ assertEquals(bindingAA0, bindingAA1);
+ assertEquals(bindingAA0, bindingAA2);
+ assertFalse(bindingAA0.equals(bindingAB));
+ assertFalse(bindingAA0.equals(bindingBA));
+ assertFalse(bindingAB.equals(bindingBA));
+ assertFalse(bindingAA0.equals(bindingAnull));
+ assertFalse(bindingBA.equals(bindingBnull));
+ assertFalse(bindingAnull.equals(bindingBnull));
+ assertEquals(bindingBnull, bindingBnull1);
+
+ assertFalse(bindingAA0.equals(new Object()));
+
+ assertFalse(bindingAA0.equals(null));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBinding#hashCode()}.
+ */
+ public void testHashCode() throws Exception
+ {
+ ServiceBinding bindingAA0 = new ServiceBinding("A", "A", "192.168.0.2", 1);
+ ServiceBinding bindingAA1 = new ServiceBinding("A", "A", "192.168.0.2", 2);
+ ServiceBinding bindingAA2 = new ServiceBinding("A", "A", "192.168.0.1", 1);
+ ServiceBinding bindingAB = new ServiceBinding("A", "B", "192.168.0.2", 1);
+ ServiceBinding bindingBA = new ServiceBinding("B", "A", "192.168.0.2", 1);
+ ServiceBinding bindingAnull = new ServiceBinding("A", null, "192.168.0.2", 1);
+ ServiceBinding bindingBnull = new ServiceBinding("B", null, "192.168.0.2", 1);
+ ServiceBinding bindingBnull1 = new ServiceBinding("B", null, "192.168.0.2", 2);
+
+ assertEquals(bindingAA0.hashCode(), bindingAA1.hashCode());
+ assertEquals(bindingAA0.hashCode(), bindingAA2.hashCode());
+ assertFalse(bindingAA0.hashCode() == bindingAB.hashCode());
+ assertFalse(bindingAA0.hashCode() == bindingBA.hashCode());
+
+ // A quirk of the values means these have same hashcode
+ assertEquals(bindingAB.hashCode(), bindingBA.hashCode());
+
+ assertFalse(bindingAA0.hashCode() == bindingAnull.hashCode());
+ assertFalse(bindingBA.hashCode() == bindingBnull.hashCode());
+ assertFalse(bindingAnull.hashCode() == bindingBnull.hashCode());
+ assertEquals(bindingBnull.hashCode(), bindingBnull1.hashCode());
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,99 +1,99 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.net.InetAddress;
-
-import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
-
-/**
- * Unit tests of {@link SimpleServiceBindingValueSourceImpl}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1 $
- */
-public class SimpleServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- private SimpleServiceBindingValueSourceImpl testee;
- private InetAddress address;
-
- /**
- * Create a new SimpleServiceBindingValueSourceUnitTestCase.
- *
- * @param name name of the test
- */
- public SimpleServiceBindingValueSourceUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- testee = new SimpleServiceBindingValueSourceImpl();
- address = InetAddress.getByName(HOST);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getIntServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
- */
- public void testGetIntServiceBindingValue()
- {
- assertEquals(PORT, testee.getIntServiceBindingValue(binding));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getInetAddressServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
- */
- public void testGetInetAddressServiceBindingValue()
- {
- assertEquals(address, testee.getInetAddressServiceBindingValue(binding));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.Object[])}.
- * @throws Exception
- */
- public void testGetServiceBindingValue() throws Exception
- {
- Object[] params = null;
- assertEquals("Correct generic value", new Integer(PORT), testee.getServiceBindingValue(binding, params));
- }
-
- public void testGetServiceBindingValueBadParam() throws Exception
- {
- try
- {
- testee.getServiceBindingValue(binding, new Object());
- fail("Should fail passing a param");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testUnknownConfigObject() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(new Object());
- assertEquals(PORT, testee.getIntServiceBindingValue(binding));
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+
+import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
+
+/**
+ * Unit tests of {@link SimpleServiceBindingValueSourceImpl}.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class SimpleServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{
+ private SimpleServiceBindingValueSourceImpl testee;
+ private InetAddress address;
+
+ /**
+ * Create a new SimpleServiceBindingValueSourceUnitTestCase.
+ *
+ * @param name name of the test
+ */
+ public SimpleServiceBindingValueSourceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ testee = new SimpleServiceBindingValueSourceImpl();
+ address = InetAddress.getByName(HOST);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getIntServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
+ */
+ public void testGetIntServiceBindingValue()
+ {
+ assertEquals(PORT, testee.getIntServiceBindingValue(binding));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getInetAddressServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
+ */
+ public void testGetInetAddressServiceBindingValue()
+ {
+ assertEquals(address, testee.getInetAddressServiceBindingValue(binding));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.Object[])}.
+ * @throws Exception
+ */
+ public void testGetServiceBindingValue() throws Exception
+ {
+ Object[] params = null;
+ assertEquals("Correct generic value", new Integer(PORT), testee.getServiceBindingValue(binding, params));
+ }
+
+ public void testGetServiceBindingValueBadParam() throws Exception
+ {
+ try
+ {
+ testee.getServiceBindingValue(binding, new Object());
+ fail("Should fail passing a param");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testUnknownConfigObject() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(new Object());
+ assertEquals(PORT, testee.getIntServiceBindingValue(binding));
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,241 +1,241 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.net.URL;
-
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
-import org.w3c.dom.Element;
-
-/**
- * Tests of {@link StringReplacementServiceBindingValueSourceImpl}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1 $
- */
-public class StringReplacementServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- private static final String INPUT = HOST_MARKER + ":" + PORT_MARKER;
- private static final String ALT_HOST_MARKER = "${alt.host}";
- private static final String ALT_PORT_MARKER = "${alt.port}";
- private static final String ALT_INPUT = ALT_HOST_MARKER + ":" + ALT_PORT_MARKER;
- private static final String OUTPUT = HOST + ":" + PORT;
- private static final String ALT_ELEMENT_INPUT = "<element host=\"" + ALT_HOST_MARKER + "\">" + ALT_PORT_MARKER + "</element>";
-
- private StringReplacementServiceBindingValueSourceImpl testee;
- private StringReplacementServiceBindingValueSourceConfig config;
-
- public StringReplacementServiceBindingValueSourceUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- testee = new StringReplacementServiceBindingValueSourceImpl();
- config = new StringReplacementServiceBindingValueSourceConfig(ALT_HOST_MARKER, ALT_PORT_MARKER);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetStringServiceBindingValue() throws Exception
- {
- assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, INPUT));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetStringServiceBindingValueNullInput() throws Exception
- {
- assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetStringServiceBindingValueOverrideMarkers() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(config);
- assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, ALT_INPUT));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
- */
- public void testGetElementServiceBindingValue() throws Exception
- {
- elementBindingTest(ELEMENT_INPUT);
- }
-
- public void testGetElementServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetElementServiceBindingValueOverrideMarkers() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(config);
- elementBindingTest(ALT_ELEMENT_INPUT);
- }
-
- private void elementBindingTest(String inputText) throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(inputText);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementServiceBindingValue(binding, input);
- validateOutputElement(output);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetResourceServiceBindingValue() throws Exception
- {
- resourceBindingTest("input.xml");
- }
-
- public void testGetResourceServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetResourceServiceBindingValueOverrideMarkers() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(config);
- resourceBindingTest("alt_input.xml");
- }
-
- private void resourceBindingTest(String inputText) throws Exception
- {
- String input = getFullyQualifiedResourceName(inputText);
- String output = testee.getResourceServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
- */
- public void testGetURLServiceBindingValue() throws Exception
- {
- urlBindingTest("input.xml");
- }
-
- public void testGetURLServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getURLServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetURLServiceBindingValueOverrideMarkers() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(config);
- urlBindingTest("alt_input.xml");
- }
-
- private void urlBindingTest(String inputText) throws Exception
- {
- String resource = getFullyQualifiedResourceName(inputText);
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetServiceBindingValueNullInput() throws Exception
- {
- Object[] params = null;
- assertEquals(HOST, testee.getServiceBindingValue(binding, params));
- }
-
- public void testGetServiceBindingValueBadInput() throws Exception
- {
- try
- {
- testee.getServiceBindingValue(binding, new Object());
- fail("Should fail passing an unknown input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueStringInput() throws Exception
- {
- assertEquals(OUTPUT, testee.getServiceBindingValue(binding, INPUT));
- }
-
- public void testGetServiceBindingValueElementInput() throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = (Element) testee.getServiceBindingValue(binding, input);
- validateOutputElement(output);
- }
-
- public void testGetServiceBindingValueURLInput() throws Exception
- {
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = (URL) testee.getServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetServiceBindingValueOverrideMarkers() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(config);
- assertEquals(OUTPUT, testee.getServiceBindingValue(binding, ALT_INPUT));
- }
-
- public void testUnknownConfigObject() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(new Object());
- assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.net.URL;
+
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Tests of {@link StringReplacementServiceBindingValueSourceImpl}.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class StringReplacementServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{
+ private static final String INPUT = HOST_MARKER + ":" + PORT_MARKER;
+ private static final String ALT_HOST_MARKER = "${alt.host}";
+ private static final String ALT_PORT_MARKER = "${alt.port}";
+ private static final String ALT_INPUT = ALT_HOST_MARKER + ":" + ALT_PORT_MARKER;
+ private static final String OUTPUT = HOST + ":" + PORT;
+ private static final String ALT_ELEMENT_INPUT = "<element host=\"" + ALT_HOST_MARKER + "\">" + ALT_PORT_MARKER + "</element>";
+
+ private StringReplacementServiceBindingValueSourceImpl testee;
+ private StringReplacementServiceBindingValueSourceConfig config;
+
+ public StringReplacementServiceBindingValueSourceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ testee = new StringReplacementServiceBindingValueSourceImpl();
+ config = new StringReplacementServiceBindingValueSourceConfig(ALT_HOST_MARKER, ALT_PORT_MARKER);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+ */
+ public void testGetStringServiceBindingValue() throws Exception
+ {
+ assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, INPUT));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+ */
+ public void testGetStringServiceBindingValueNullInput() throws Exception
+ {
+ assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+ */
+ public void testGetStringServiceBindingValueOverrideMarkers() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(config);
+ assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, ALT_INPUT));
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
+ */
+ public void testGetElementServiceBindingValue() throws Exception
+ {
+ elementBindingTest(ELEMENT_INPUT);
+ }
+
+ public void testGetElementServiceBindingValueNullInput() throws Exception
+ {
+ try
+ {
+ testee.getResourceServiceBindingValue(binding, null);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetElementServiceBindingValueOverrideMarkers() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(config);
+ elementBindingTest(ALT_ELEMENT_INPUT);
+ }
+
+ private void elementBindingTest(String inputText) throws Exception
+ {
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ editor.setAsText(inputText);
+ Element input = (Element) editor.getValue();
+ Element output = testee.getElementServiceBindingValue(binding, input);
+ validateOutputElement(output);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+ */
+ public void testGetResourceServiceBindingValue() throws Exception
+ {
+ resourceBindingTest("input.xml");
+ }
+
+ public void testGetResourceServiceBindingValueNullInput() throws Exception
+ {
+ try
+ {
+ testee.getResourceServiceBindingValue(binding, null);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetResourceServiceBindingValueOverrideMarkers() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(config);
+ resourceBindingTest("alt_input.xml");
+ }
+
+ private void resourceBindingTest(String inputText) throws Exception
+ {
+ String input = getFullyQualifiedResourceName(inputText);
+ String output = testee.getResourceServiceBindingValue(binding, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
+ */
+ public void testGetURLServiceBindingValue() throws Exception
+ {
+ urlBindingTest("input.xml");
+ }
+
+ public void testGetURLServiceBindingValueNullInput() throws Exception
+ {
+ try
+ {
+ testee.getURLServiceBindingValue(binding, null);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetURLServiceBindingValueOverrideMarkers() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(config);
+ urlBindingTest("alt_input.xml");
+ }
+
+ private void urlBindingTest(String inputText) throws Exception
+ {
+ String resource = getFullyQualifiedResourceName(inputText);
+ URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+ URL output = testee.getURLServiceBindingValue(binding, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ public void testGetServiceBindingValueNullInput() throws Exception
+ {
+ Object[] params = null;
+ assertEquals(HOST, testee.getServiceBindingValue(binding, params));
+ }
+
+ public void testGetServiceBindingValueBadInput() throws Exception
+ {
+ try
+ {
+ testee.getServiceBindingValue(binding, new Object());
+ fail("Should fail passing an unknown input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetServiceBindingValueStringInput() throws Exception
+ {
+ assertEquals(OUTPUT, testee.getServiceBindingValue(binding, INPUT));
+ }
+
+ public void testGetServiceBindingValueElementInput() throws Exception
+ {
+ PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+ editor.setAsText(ELEMENT_INPUT);
+ Element input = (Element) editor.getValue();
+ Element output = (Element) testee.getServiceBindingValue(binding, input);
+ validateOutputElement(output);
+ }
+
+ public void testGetServiceBindingValueURLInput() throws Exception
+ {
+ String resource = getFullyQualifiedResourceName("input.xml");
+ URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+ URL output = (URL) testee.getServiceBindingValue(binding, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateOutputElement(element);
+ }
+
+ public void testGetServiceBindingValueOverrideMarkers() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(config);
+ assertEquals(OUTPUT, testee.getServiceBindingValue(binding, ALT_INPUT));
+ }
+
+ public void testUnknownConfigObject() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(new Object());
+ assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,70 +1,70 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-
-/**
- * Tests of {@link XSLTServiceBindingValueSourceConfig}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1 $
- */
-public class XSLTServiceBindingValueSourceConfigUnitTestCase extends TestCase
-{
-
- /**
- * Create a new XSLTServiceBindingValueSourceConfigUnitTestCase.
- *
- * @param arg0
- */
- public XSLTServiceBindingValueSourceConfigUnitTestCase(String arg0)
- {
- super(arg0);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig#getAdditionalAttributes()}.
- */
- public void testGetAdditionalAttributes()
- {
- XSLTServiceBindingValueSourceConfig config = new XSLTServiceBindingValueSourceConfig("test");
- Map<String, String> addl = config.getAdditionalAttributes();
- assertNotNull(addl);
- assertEquals(0, addl.size());
-
- addl = new HashMap<String, String>();
- addl.put("a", "a");
-
- config = new XSLTServiceBindingValueSourceConfig("test", addl);
- Map<String, String> addl1 = config.getAdditionalAttributes();
- assertEquals(addl, addl1);
-
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+
+/**
+ * Tests of {@link XSLTServiceBindingValueSourceConfig}.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class XSLTServiceBindingValueSourceConfigUnitTestCase extends TestCase
+{
+
+ /**
+ * Create a new XSLTServiceBindingValueSourceConfigUnitTestCase.
+ *
+ * @param arg0
+ */
+ public XSLTServiceBindingValueSourceConfigUnitTestCase(String arg0)
+ {
+ super(arg0);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig#getAdditionalAttributes()}.
+ */
+ public void testGetAdditionalAttributes()
+ {
+ XSLTServiceBindingValueSourceConfig config = new XSLTServiceBindingValueSourceConfig("test");
+ Map<String, String> addl = config.getAdditionalAttributes();
+ assertNotNull(addl);
+ assertEquals(0, addl.size());
+
+ addl = new HashMap<String, String>();
+ addl.put("a", "a");
+
+ config = new XSLTServiceBindingValueSourceConfig("test", addl);
+ Map<String, String> addl1 = config.getAdditionalAttributes();
+ assertEquals(addl, addl1);
+
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:03:21 UTC (rev 81080)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java 2008-11-14 17:04:40 UTC (rev 81081)
@@ -1,194 +1,194 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.services.binding.test;
-
-import java.net.URL;
-
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-import org.w3c.dom.Element;
-
-/**
- * Tests of {@link XSLTServiceBindingValueSourceImpl}.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class XSLTServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- private XSLTServiceBindingValueSourceImpl testee;
- private XSLTServiceBindingValueSourceConfig xsltConfig;
-
- /**
- * Create a new XSLTServiceBindingValueSourceUnitTestCase.
- *
- * @param name
- */
- public XSLTServiceBindingValueSourceUnitTestCase(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- testee = new XSLTServiceBindingValueSourceImpl();
- xsltConfig = getXSLTConfig();
- binding.setServiceBindingValueSourceConfig(xsltConfig);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
- */
- public void testGetElementServiceBindingValue() throws Exception
- {
- Element input = getDocumentElementFromClasspath(XSL_INPUT);
- Element output = testee.getElementServiceBindingValue(binding, input);
- validateXSLTOutputElement(output);
- }
-
- public void testGetElementServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetResourceServiceBindingValue() throws Exception
- {
- String output = testee.getResourceServiceBindingValue(binding, XSL_INPUT);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetResourceServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
- */
- public void testGetURLServiceBindingValue() throws Exception
- {
- URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
- URL output = testee.getURLServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetURLServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getURLServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueNullInput() throws Exception
- {
- Object[] params = null;
- try
- {
- testee.getServiceBindingValue(binding, params);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueBadInput() throws Exception
- {
- try
- {
- testee.getServiceBindingValue(binding, new Object());
- fail("Should fail passing an unknown input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueStringInput() throws Exception
- {
- String output = (String) testee.getServiceBindingValue(binding, XSL_INPUT);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetServiceBindingValueElementInput() throws Exception
- {
- Element input = getDocumentElementFromClasspath(XSL_INPUT);
- Element output = (Element) testee.getServiceBindingValue(binding, input);
- validateXSLTOutputElement(output);
- }
-
- public void testGetServiceBindingValueURLInput() throws Exception
- {
- URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
- URL output = (URL) testee.getServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testNullConfigObject() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(null);
- String input = getFullyQualifiedResourceName("xlst_input.xml");
- try
- {
- testee.getResourceServiceBindingValue(binding, input);
- fail("Should fail using an unknown xsltConfig");
- }
- catch (IllegalStateException good) {}
- }
-
- public void testUnknownConfigObject() throws Exception
- {
- binding.setServiceBindingValueSourceConfig(new Object());
- String input = getFullyQualifiedResourceName("xlst_input.xml");
- try
- {
- testee.getResourceServiceBindingValue(binding, input);
- fail("Should fail using an unknown xsltConfig");
- }
- catch (IllegalStateException good) {}
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.URL;
+
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Tests of {@link XSLTServiceBindingValueSourceImpl}.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class XSLTServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{
+ private XSLTServiceBindingValueSourceImpl testee;
+ private XSLTServiceBindingValueSourceConfig xsltConfig;
+
+ /**
+ * Create a new XSLTServiceBindingValueSourceUnitTestCase.
+ *
+ * @param name
+ */
+ public XSLTServiceBindingValueSourceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ testee = new XSLTServiceBindingValueSourceImpl();
+ xsltConfig = getXSLTConfig();
+ binding.setServiceBindingValueSourceConfig(xsltConfig);
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
+ */
+ public void testGetElementServiceBindingValue() throws Exception
+ {
+ Element input = getDocumentElementFromClasspath(XSL_INPUT);
+ Element output = testee.getElementServiceBindingValue(binding, input);
+ validateXSLTOutputElement(output);
+ }
+
+ public void testGetElementServiceBindingValueNullInput() throws Exception
+ {
+ try
+ {
+ testee.getResourceServiceBindingValue(binding, null);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+ */
+ public void testGetResourceServiceBindingValue() throws Exception
+ {
+ String output = testee.getResourceServiceBindingValue(binding, XSL_INPUT);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateXSLTOutputElement(element);
+ }
+
+ public void testGetResourceServiceBindingValueNullInput() throws Exception
+ {
+ try
+ {
+ testee.getResourceServiceBindingValue(binding, null);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
+ */
+ public void testGetURLServiceBindingValue() throws Exception
+ {
+ URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
+ URL output = testee.getURLServiceBindingValue(binding, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateXSLTOutputElement(element);
+ }
+
+ public void testGetURLServiceBindingValueNullInput() throws Exception
+ {
+ try
+ {
+ testee.getURLServiceBindingValue(binding, null);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetServiceBindingValueNullInput() throws Exception
+ {
+ Object[] params = null;
+ try
+ {
+ testee.getServiceBindingValue(binding, params);
+ fail("Should fail passing a null input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetServiceBindingValueBadInput() throws Exception
+ {
+ try
+ {
+ testee.getServiceBindingValue(binding, new Object());
+ fail("Should fail passing an unknown input");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ public void testGetServiceBindingValueStringInput() throws Exception
+ {
+ String output = (String) testee.getServiceBindingValue(binding, XSL_INPUT);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateXSLTOutputElement(element);
+ }
+
+ public void testGetServiceBindingValueElementInput() throws Exception
+ {
+ Element input = getDocumentElementFromClasspath(XSL_INPUT);
+ Element output = (Element) testee.getServiceBindingValue(binding, input);
+ validateXSLTOutputElement(output);
+ }
+
+ public void testGetServiceBindingValueURLInput() throws Exception
+ {
+ URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
+ URL output = (URL) testee.getServiceBindingValue(binding, input);
+ assertNotNull(output);
+ Element element = getDocumentElement(output);
+ validateXSLTOutputElement(element);
+ }
+
+ public void testNullConfigObject() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(null);
+ String input = getFullyQualifiedResourceName("xlst_input.xml");
+ try
+ {
+ testee.getResourceServiceBindingValue(binding, input);
+ fail("Should fail using an unknown xsltConfig");
+ }
+ catch (IllegalStateException good) {}
+ }
+
+ public void testUnknownConfigObject() throws Exception
+ {
+ binding.setServiceBindingValueSourceConfig(new Object());
+ String input = getFullyQualifiedResourceName("xlst_input.xml");
+ try
+ {
+ testee.getResourceServiceBindingValue(binding, input);
+ fail("Should fail using an unknown xsltConfig");
+ }
+ catch (IllegalStateException good) {}
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list