You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2008/10/01 16:10:12 UTC
svn commit: r700775 - in /webservices/juddi/branches/v3_trunk: ./
juddi-core/src/main/java/org/apache/juddi/api/impl/
juddi-core/src/main/java/org/apache/juddi/config/
juddi-core/src/main/java/org/apache/juddi/error/
juddi-core/src/main/resources/ judd...
Author: kstam
Date: Wed Oct 1 07:10:11 2008
New Revision: 700775
URL: http://svn.apache.org/viewvc?rev=700775&view=rev
Log:
JUDDI-133, Initial checking on the configuration manager
Added:
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java (contents, props changed)
- copied, changed from r700743, webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/juddi.properties
webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/ApplicationConfigurationTest.java
webservices/juddi/branches/v3_trunk/juddi-core/src/test/resources/log4j.xml
Removed:
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java
Modified:
webservices/juddi/branches/v3_trunk/ (props changed)
webservices/juddi/branches/v3_trunk/.classpath
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java
webservices/juddi/branches/v3_trunk/pom.xml
Propchange: webservices/juddi/branches/v3_trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Oct 1 07:10:11 2008
@@ -1,2 +1,3 @@
target-eclipse
.settings
+test-output
Modified: webservices/juddi/branches/v3_trunk/.classpath
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/.classpath?rev=700775&r1=700774&r2=700775&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/.classpath (original)
+++ webservices/juddi/branches/v3_trunk/.classpath Wed Oct 1 07:10:11 2008
@@ -1,10 +1,12 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="uddi-ws/src/main/java"/>
- <classpathentry kind="src" path="uddi-ws/src/main/resources"/>
- <classpathentry kind="src" path="juddi-core/src/main/resources"/>
- <classpathentry kind="src" path="juddi-core/src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target-eclipse/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="juddi-core/src/main/java"/>
+ <classpathentry kind="src" path="juddi-core/src/main/resources"/>
+ <classpathentry kind="src" path="juddi-core/src/test/java"/>
+ <classpathentry kind="src" path="juddi-core/src/test/resources"/>
+ <classpathentry kind="src" path="uddi-ws/src/main/java"/>
+ <classpathentry kind="src" path="uddi-ws/src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
+</classpath>
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java?rev=700775&r1=700774&r2=700775&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java Wed Oct 1 07:10:11 2008
@@ -25,7 +25,7 @@
import javax.persistence.EntityTransaction;
import javax.persistence.EntityManager;
-import org.apache.juddi.config.Configuration;
+import org.apache.juddi.config.ResourceConfig;
import org.apache.juddi.error.UDDIErrorHelper;
import org.apache.juddi.mapping.MappingModelToApi;
import org.apache.juddi.util.JPAUtil;
@@ -105,7 +105,7 @@
org.apache.juddi.model.BindingTemplate modelBindingTemplate = em.find(org.apache.juddi.model.BindingTemplate.class, bindingKey);
if (modelBindingTemplate == null) {
- throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.BindingTemplateNotFound") + ": " + bindingKey,
+ throw new DispositionReportFaultMessage(ResourceConfig.getGlobalMessage("errors.invalidkey.BindingTemplateNotFound") + ": " + bindingKey,
UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
}
@@ -142,7 +142,7 @@
org.apache.juddi.model.BusinessEntity modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, businessKey);
if (modelBusinessEntity == null) {
- throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.BusinessNotFound") + ": " + businessKey,
+ throw new DispositionReportFaultMessage(ResourceConfig.getGlobalMessage("errors.invalidkey.BusinessNotFound") + ": " + businessKey,
UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
}
@@ -185,7 +185,7 @@
org.apache.juddi.model.BusinessService modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
if (modelBusinessService == null) {
- throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.ServiceNotFound") + ": " + serviceKey,
+ throw new DispositionReportFaultMessage(ResourceConfig.getGlobalMessage("errors.invalidkey.ServiceNotFound") + ": " + serviceKey,
UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
}
@@ -222,7 +222,7 @@
org.apache.juddi.model.Tmodel modelTModel = em.find(org.apache.juddi.model.Tmodel.class, tmodelKey);
if (modelTModel == null) {
- throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.TModelNotFound") + ": " + tmodelKey,
+ throw new DispositionReportFaultMessage(ResourceConfig.getGlobalMessage("errors.invalidkey.TModelNotFound") + ": " + tmodelKey,
UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
}
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java?rev=700775&r1=700774&r2=700775&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java Wed Oct 1 07:10:11 2008
@@ -48,7 +48,7 @@
import org.apache.juddi.mapping.MappingApiToModel;
import org.apache.juddi.util.JPAUtil;
import org.apache.juddi.error.UDDIErrorHelper;
-import org.apache.juddi.config.Configuration;
+import org.apache.juddi.config.ResourceConfig;
/**
* @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
@@ -194,7 +194,7 @@
//TODO: Validate the input here
if (JPAUtil.getEntity(org.apache.juddi.model.BusinessService.class, apiBindingTemplate.getServiceKey()) == null) {
- throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.ServiceNotFound") + ": " + apiBindingTemplate.getServiceKey(),
+ throw new DispositionReportFaultMessage(ResourceConfig.getGlobalMessage("errors.invalidkey.ServiceNotFound") + ": " + apiBindingTemplate.getServiceKey(),
UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
}
//TODO: Test if key is null, and if so, apply key-generation strategy
@@ -258,7 +258,7 @@
//TODO: Validate the input here
if (JPAUtil.getEntity(org.apache.juddi.model.BusinessEntity.class, apiBusinessService.getBusinessKey()) == null) {
- throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.BusinessNotFound") + ": " + apiBusinessService.getBusinessKey(),
+ throw new DispositionReportFaultMessage(ResourceConfig.getGlobalMessage("errors.invalidkey.BusinessNotFound") + ": " + apiBusinessService.getBusinessKey(),
UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
}
//TODO: Test if key is null, and if so, apply key-generation strategy
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java?rev=700775&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java Wed Oct 1 07:10:11 2008
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.juddi.config;
+
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
+import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
+import org.apache.log4j.Logger;
+
+/**
+ * Handles the application level configuration for jUDDI. By default it first
+ * looks at system properties
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ */
+public class AppConfig
+{
+ private final static String JUDDI_PROPERTIES = "juddi.properties";
+ private Logger log = Logger.getLogger(AppConfig.class);
+ private Configuration config;
+ private static AppConfig instance=null;
+
+ /**
+ * Constructor (note Singleton pattern).
+ * @throws ConfigurationException
+ */
+ private AppConfig() throws ConfigurationException
+ {
+ loadConfiguration();
+ }
+ /**
+ * Does the actual work of reading the configuration from System
+ * Properties and/or juddi.properties file. When the juddi.properties
+ * file is updated the file will be reloaded. By default the reloadDelay is
+ * set to 1 second to prevent excessive date stamp checking.
+ */
+ private void loadConfiguration() throws ConfigurationException
+ {
+ //Properties from system properties
+ CompositeConfiguration compositeConfig = new CompositeConfiguration();
+ compositeConfig.addConfiguration(new SystemConfiguration());
+ //Properties from file
+ PropertiesConfiguration propConfig = new PropertiesConfiguration(JUDDI_PROPERTIES);
+ long refreshDelay = propConfig.getLong(Property.JUDDI_RELOAD_DELAY, 1000l);
+ log.debug("Setting refreshDelay to " + refreshDelay);
+ FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
+ fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
+ propConfig.setReloadingStrategy(fileChangedReloadingStrategy);
+ compositeConfig.addConfiguration(propConfig);
+ //Making the new configuration globally accessible.
+ config = compositeConfig;
+ }
+ /**
+ * Obtains the reference to the Singleton instance.
+ *
+ * @return the APplicationConfuration Singleton Instance.
+ * @throws ConfigurationException
+ */
+ public static AppConfig getInstance() throws ConfigurationException
+ {
+ if (instance==null) {
+ instance = new AppConfig();
+ }
+ return instance;
+ }
+ /**
+ * Hook to receive configuration reload events from an external application.
+ *
+ * @throws ConfigurationException
+ */
+ public static void reloadConfig() throws ConfigurationException
+ {
+ getInstance().loadConfiguration();
+ }
+ /**
+ * The object from which property values can be obtained.
+ * @return the commons Configuration interface
+ * @throws ConfigurationException
+ */
+ public static Configuration getConfiguration() throws ConfigurationException
+ {
+ return getInstance().config;
+ }
+}
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java?rev=700775&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java Wed Oct 1 07:10:11 2008
@@ -0,0 +1,6 @@
+package org.apache.juddi.config;
+
+public interface Property
+{
+ public final static String JUDDI_RELOAD_DELAY = "juddi.reload.delay";
+}
Copied: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java (from r700743, webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java)
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java?p2=webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java&p1=webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java&r1=700743&r2=700775&rev=700775&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java Wed Oct 1 07:10:11 2008
@@ -23,7 +23,7 @@
/**
* @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
*/
-public class Configuration {
+public class ResourceConfig {
public static final String GLOBAL_MESSAGES_FILE = "messages";
private static final ResourceBundle globalMessages;
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/ResourceConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java?rev=700775&r1=700774&r2=700775&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java Wed Oct 1 07:10:11 2008
@@ -17,7 +17,7 @@
package org.apache.juddi.error;
-import org.apache.juddi.config.Configuration;
+import org.apache.juddi.config.ResourceConfig;
import org.uddi.api_v3.DispositionReport;
import org.uddi.api_v3.Result;
import org.uddi.api_v3.ErrInfo;
@@ -104,7 +104,7 @@
String errCode = lookupErrCode(errno);
if (errCode == null)
return null;
- return Configuration.getGlobalMessage(errCode);
+ return ResourceConfig.getGlobalMessage(errCode);
}
public static final DispositionReport buildDispositionReport(int errNo) {
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/juddi.properties
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/juddi.properties?rev=700775&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/juddi.properties (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/juddi.properties Wed Oct 1 07:10:11 2008
@@ -0,0 +1 @@
+juddi.reload.delay=2000
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/ApplicationConfigurationTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/ApplicationConfigurationTest.java?rev=700775&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/ApplicationConfigurationTest.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/ApplicationConfigurationTest.java Wed Oct 1 07:10:11 2008
@@ -0,0 +1,23 @@
+package org.apache.juddi.test;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.Property;
+import org.testng.annotations.Test;
+
+public class ApplicationConfigurationTest
+{
+ @Test
+ public void readPropertyFromFile() throws ConfigurationException
+ {
+ long refreshDelay = AppConfig.getConfiguration().getLong(Property.JUDDI_RELOAD_DELAY);
+ System.out.println(refreshDelay);
+ }
+
+ @Test
+ public void readNonExistingProperty() throws ConfigurationException
+ {
+ long nonexisting = AppConfig.getConfiguration().getLong("nonexisting.property",3000l);
+ System.out.println(nonexisting);
+ }
+}
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/resources/log4j.xml?rev=700775&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/resources/log4j.xml (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/resources/log4j.xml Wed Oct 1 07:10:11 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="DEBUG"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <logger name="org">
+ <level value="DEBUG"/>
+ </logger>
+
+ <logger name="com">
+ <level value="DEBUG"/>
+ </logger>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+
+</log4j:configuration>
Modified: webservices/juddi/branches/v3_trunk/pom.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/pom.xml?rev=700775&r1=700774&r2=700775&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/pom.xml (original)
+++ webservices/juddi/branches/v3_trunk/pom.xml Wed Oct 1 07:10:11 2008
@@ -171,5 +171,20 @@
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.13</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org