You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/09/05 08:07:47 UTC
svn commit: r1381015 - in /incubator/airavata/trunk: ./
modules/commons/common-registry-api/src/main/java/org/apache/airavata/common/registry/api/exception/
modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/
modules/commons/re...
Author: samindaw
Date: Wed Sep 5 06:07:46 2012
New Revision: 1381015
URL: http://svn.apache.org/viewvc?rev=1381015&view=rev
Log:
introducing AiravataRegistryFactory class
Added:
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java (with props)
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java (with props)
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java (with props)
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java (with props)
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java (with props)
incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java (with props)
incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java (with props)
Modified:
incubator/airavata/trunk/modules/commons/common-registry-api/src/main/java/org/apache/airavata/common/registry/api/exception/RegistryException.java
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
incubator/airavata/trunk/pom.xml
Modified: incubator/airavata/trunk/modules/commons/common-registry-api/src/main/java/org/apache/airavata/common/registry/api/exception/RegistryException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/common-registry-api/src/main/java/org/apache/airavata/common/registry/api/exception/RegistryException.java?rev=1381015&r1=1381014&r2=1381015&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/common-registry-api/src/main/java/org/apache/airavata/common/registry/api/exception/RegistryException.java (original)
+++ incubator/airavata/trunk/modules/commons/common-registry-api/src/main/java/org/apache/airavata/common/registry/api/exception/RegistryException.java Wed Sep 5 06:07:46 2012
@@ -31,6 +31,10 @@ public class RegistryException extends E
super(ERROR_MESSAGE, e);
}
+ public RegistryException(String message) {
+ super(message, null);
+ }
+
public RegistryException(String message, Exception e) {
super(message, e);
}
Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java?rev=1381015&r1=1381014&r2=1381015&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java Wed Sep 5 06:07:46 2012
@@ -26,14 +26,12 @@ public abstract class AiravataRegistry2
private Gateway gateway;
private AiravataUser user;
- public AiravataRegistry2(Gateway gateway, AiravataUser user) {
+ public void preInitialize(Gateway gateway, AiravataUser user) {
setGateway(gateway);
setUser(user);
}
- public AiravataRegistry2(String gatewayName, String userName) {
- this(new Gateway(gatewayName), new AiravataUser(userName));
- }
+ protected abstract void initialize();
public Gateway getGateway() {
return gateway;
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,120 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.registry.api;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.airavata.common.exception.AiravataConfigurationException;
+import org.apache.airavata.registry.api.exception.RegistryAccessorInstantiateException;
+import org.apache.airavata.registry.api.exception.RegistryAccessorInvalidException;
+import org.apache.airavata.registry.api.exception.RegistryAccessorNotFoundException;
+import org.apache.airavata.registry.api.exception.RegistryAccessorUndefinedException;
+
+public class AiravataRegistryFactory {
+
+ private static final String REPOSITORY_PROPERTIES = "repository.properties";
+ private static final String REGISTRY_ACCESSOR_CLASS = "class.registry.accessor";
+
+ /***
+ * Return a registry accessor object capable of handling all data in the
+ * registry
+ *
+ * @param gateway
+ * @param user
+ * @return
+ * @throws RegistryAccessorNotFoundException
+ * @throws RegistryAccessorUndefinedException
+ * @throws RegistryAccessorInstantiateException
+ * @throws AiravataConfigurationException
+ * @throws RegistryAccessorInvalidException
+ */
+ public static AiravataRegistry2 getRegistry(Gateway gateway,
+ AiravataUser user) throws RegistryAccessorNotFoundException,
+ RegistryAccessorUndefinedException,
+ RegistryAccessorInstantiateException,
+ AiravataConfigurationException, RegistryAccessorInvalidException {
+ Object registryObj = getRegistryClass(REGISTRY_ACCESSOR_CLASS);
+ if (registryObj instanceof AiravataRegistry2) {
+ AiravataRegistry2 registry = (AiravataRegistry2) registryObj;
+ registry.preInitialize(gateway, user);
+ registry.initialize();
+ return registry;
+ }
+ throw new RegistryAccessorInvalidException(registryObj.getClass()
+ .getName());
+ }
+
+ /***
+ * Given the key in the <code>REPOSITORY_PROPERTIES</code> file it will
+ * attempt to instantiate a class from the value of the property
+ *
+ * @param registryClassKey
+ * @return
+ * @throws RegistryAccessorNotFoundException
+ * @throws RegistryAccessorUndefinedException
+ * @throws RegistryAccessorInstantiateException
+ * @throws AiravataConfigurationException
+ */
+ private static Object getRegistryClass(String registryClassKey)
+ throws RegistryAccessorNotFoundException,
+ RegistryAccessorUndefinedException,
+ RegistryAccessorInstantiateException,
+ AiravataConfigurationException {
+ Properties properties = new Properties();
+ URL url = AiravataRegistryFactory.class.getClassLoader().getResource(
+ REPOSITORY_PROPERTIES);
+ if (url != null) {
+ try {
+ properties.load(url.openStream());
+ String provRegAccessorClass = properties.getProperty(
+ registryClassKey, null);
+ if (provRegAccessorClass == null) {
+ throw new RegistryAccessorUndefinedException();
+ } else {
+ try {
+ Class<?> classInstance = AiravataRegistryFactory.class
+ .getClassLoader().loadClass(
+ provRegAccessorClass);
+ return classInstance.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new RegistryAccessorNotFoundException(
+ provRegAccessorClass, e);
+ } catch (InstantiationException e) {
+ throw new RegistryAccessorInstantiateException(
+ provRegAccessorClass, e);
+ } catch (IllegalAccessException e) {
+ throw new RegistryAccessorInstantiateException(
+ provRegAccessorClass, e);
+ }
+ }
+ } catch (IOException e) {
+ throw new AiravataConfigurationException(
+ "Error reading the configuration file", e);
+ }
+ }
+ return null;
+
+ }
+
+}
Propchange: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.registry.api.exception;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+
+public class RegistryAccessorInstantiateException extends RegistryException {
+
+ private static final long serialVersionUID = -2679914107485739140L;
+
+ public RegistryAccessorInstantiateException(String className, Exception e){
+ super("There was an exception instantiating the Registry accessor class '"+className+"'!!!", e);
+ }
+
+}
Propchange: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.registry.api.exception;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+
+public class RegistryAccessorInvalidException extends RegistryException {
+
+ private static final long serialVersionUID = -2679914107485739140L;
+
+ public RegistryAccessorInvalidException(String className){
+ super("Registry accessor '"+className+"' is not valid!!!");
+ }
+
+}
Propchange: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.registry.api.exception;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+
+public class RegistryAccessorNotFoundException extends RegistryException {
+
+ private static final long serialVersionUID = -2679914107485739140L;
+
+ public RegistryAccessorNotFoundException(String className, Exception e){
+ super("Registry accessor class '"+className+"' was not found in classpath!!!", e);
+ }
+
+}
Propchange: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.registry.api.exception;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+
+public class RegistryAccessorUndefinedException extends RegistryException {
+
+ private static final long serialVersionUID = -2679914107485739140L;
+
+ public RegistryAccessorUndefinedException() {
+ this("A registry accessor was not defined in the repository.properties");
+ }
+
+ public RegistryAccessorUndefinedException(String message) {
+ this(message,null);
+ }
+
+ public RegistryAccessorUndefinedException(String message, Exception e){
+ super(message, e);
+ }
+
+}
Propchange: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java (added)
+++ incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.common.exception;
+
+public class AiravataConfigurationException extends AiravataException {
+ private static final long serialVersionUID = -9124231436834631249L;
+
+ public AiravataConfigurationException() {
+ }
+
+ public AiravataConfigurationException(String message){
+ this(message, null);
+ }
+
+ public AiravataConfigurationException(String message, Throwable e){
+ super(message,e);
+ }
+}
Propchange: incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java?rev=1381015&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java (added)
+++ incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java Wed Sep 5 06:07:46 2012
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.airavata.common.exception;
+
+public class AiravataException extends Exception {
+
+ private static final long serialVersionUID = -5665822765183116821L;
+ public AiravataException() {
+ }
+
+ public AiravataException(String message, Throwable e) {
+ super(message,e);
+ }
+
+ public AiravataException(String message) {
+ super(message);
+ }
+}
Propchange: incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/AiravataException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/airavata/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/pom.xml?rev=1381015&r1=1381014&r2=1381015&view=diff
==============================================================================
--- incubator/airavata/trunk/pom.xml (original)
+++ incubator/airavata/trunk/pom.xml Wed Sep 5 06:07:46 2012
@@ -364,6 +364,7 @@
<module>modules/gfac-core</module>
<module>modules/gfac-axis2</module>
<module>modules/commons</module>
+ <module>modules/registry</module>
</modules>
</profile>
<profile>
@@ -388,6 +389,7 @@
</activation>
<modules>
<module>modules/commons</module>
+ <module>modules/registry</module>
<module>modules/ws-messenger</module>
<module>modules/workflow-model</module>
<module>modules/xbaya-gui</module>
@@ -405,6 +407,7 @@
</activation>
<modules>
<module>modules/commons</module>
+ <module>modules/registry</module>
</modules>
</profile>
@@ -431,6 +434,7 @@
</activation>
<modules>
<module>modules/commons</module>
+ <module>modules/registry</module>
<module>modules/ws-messenger</module>
<module>modules/workflow-model</module>
<module>modules/xbaya-gui</module>
@@ -460,6 +464,7 @@
</activation>
<modules>
<module>modules/commons</module>
+ <module>modules/registry</module>
<module>modules/ws-messenger</module>
<module>modules/workflow-model</module>
<module>modules/xbaya-gui</module>
@@ -585,6 +590,7 @@
<module>modules/workflow-model</module>
<module>modules/xbaya-gui</module>
<module>modules/commons</module>
+ <module>modules/registry</module>
<module>modules/airavata-client</module>
<module>samples/simple-math-service</module>
<module>samples/complex-math-service</module>