You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by hu...@apache.org on 2009/10/02 13:59:31 UTC
svn commit: r820982 [2/2] - in /incubator/aries/contrib/ibm:
com.ibm.osgi.web/ com.ibm.osgi.web/META-INF/ com.ibm.osgi.web/OSGI-INF/
com.ibm.osgi.web/OSGI-INF/blueprint/ com.ibm.osgi.web/src/
com.ibm.osgi.web/src/com/ com.ibm.osgi.web/src/com/ibm/ com....
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadataFactory.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadataFactory.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadataFactory.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadataFactory.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,43 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.websphere.application.aries;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.jar.Manifest;
+
+public class ApplicationMetadataFactory {
+
+ private static String implClass = "com.ibm.ws.eba.app.api.ApplicationMetadataImpl";
+
+ /**
+ * Obtain an ApplicationMetadata for the supplied Manifest.
+ *
+ * @param mf The manifest containing application metadata
+ * @return instance of ApplicationMetadata
+ * @throws IllegalArgumentException if the Manifest does not contain application metadata
+ */
+ @SuppressWarnings("unchecked")
+ public static ApplicationMetadata getApplicationMetadata(Manifest mf)
+ throws IllegalArgumentException
+ {
+ try{
+ Class impl = Class.forName(implClass);
+ Constructor c = impl.getConstructor(Manifest.class);
+ return (ApplicationMetadata)c.newInstance(mf);
+ }catch(ClassNotFoundException e){
+ throw new RuntimeException("Unable to find metadata impl class ",e);
+ } catch (SecurityException e) {
+ throw new RuntimeException("Unable to access metadata impl constructor ",e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Unable to find metadata impl constructor ",e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Unable to create metadata impl constructor ",e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Unable to access metadata impl constructor ",e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException("Unable to invoke metadata impl constructor ",e);
+ }
+ }
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadataFactory.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/Content.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/Content.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/Content.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/Content.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.websphere.application.aries;
+
+import java.util.Map;
+
+
+/**
+ * this interface describes the content metadata such as Application-Content, Import-Package, etc
+ *
+ */
+public interface Content
+{
+ /**
+ * get the package name of the content
+ * @return the package name of the content
+ */
+ public String getContentName();
+
+ /**
+ * get the entire content including the content name, directives & attributes
+ * @return the entire content in String format
+ */
+ public String getContent();
+
+ /**
+ * get the attributes of the content
+ * @return the attributes of the content
+ */
+ public Map<String, String> getAttributes();
+
+ /**
+ * get the directives of the content
+ * @return the directives of the content
+ */
+ public Map<String, String> getDirectives();
+
+ /**
+ * get the value of the attribute with the specified key
+ * @param key
+ * @return value of the attribute specified by the key
+ */
+ public String getAttribute(String key);
+
+ /**
+ * get the value of the directive with the specified key
+ * @param key
+ * @return the value of the directive specified by the key
+ */
+ public String getDirective(String key);
+
+ /**
+ * get the version info for the version attribute
+ * @return null if there is no version associated with this content
+ * ASK ALASDAIR: should we return default version 0.0.0 instead of null?
+ */
+ public VersionRange getVersion();
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/Content.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ServiceDeclaration.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ServiceDeclaration.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ServiceDeclaration.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ServiceDeclaration.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,22 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.websphere.application.aries;
+
+import org.osgi.framework.Filter;
+
+public interface ServiceDeclaration {
+
+ /**
+ * get the interface name for the service
+ * @return
+ */
+ public abstract String getInterfaceName();
+
+ /**
+ * get the filter for the service
+ * @return the filter for the service or null if there is no filter defined
+ */
+ public abstract Filter getFilter();
+
+}
\ No newline at end of file
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ServiceDeclaration.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/VersionRange.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/VersionRange.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/VersionRange.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/VersionRange.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.websphere.application.aries;
+
+import org.osgi.framework.Version;
+
+public interface VersionRange {
+
+ public abstract String toString();
+
+ /**
+ * this method returns the exact version from the versionInfo obj.
+ * this is used for DeploymentContent only to return a valid exact version
+ * otherwise, null is returned.
+ * @return
+ */
+ public abstract Version getExactVersion();
+
+ /**
+ * get the maximum version
+ * @return the maximum version
+ */
+ public abstract Version getMaximumVersion();
+
+ /**
+ * get the minimum version
+ * @return the minimum version
+ */
+ public abstract Version getMinimumVersion();
+
+ /**
+ * is the maximum version exclusive
+ * @return
+ */
+ public abstract boolean isMaximumExclusive();
+
+ /**
+ * is the maximum version unbounded
+ * @return
+ */
+ public abstract boolean isMaximumUnbounded();
+
+ /**
+ * is the minimum version exclusive
+ * @return
+ */
+ public abstract boolean isMinimumExclusive();
+
+ /**
+ * check if the versioninfo is the exact version
+ * @return
+ */
+ public abstract boolean isExactVersion();
+
+}
\ No newline at end of file
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/VersionRange.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ApplicationMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ApplicationMetadataImpl.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ApplicationMetadataImpl.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ApplicationMetadataImpl.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,145 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.api;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.osgi.framework.Version;
+
+import com.ibm.websphere.application.aries.ApplicationMetadata;
+import com.ibm.websphere.application.aries.Content;
+import com.ibm.websphere.application.aries.ServiceDeclaration;
+import com.ibm.ws.eba.app.utils.AppConstants;
+import com.ibm.ws.eba.app.utils.manifest.ManifestProcessor;
+
+/**
+ * Implementation of ApplicationMetadata and DeploymentMetadata
+ *
+ */
+public class ApplicationMetadataImpl implements ApplicationMetadata
+{
+ private String appSymbolicName;
+ private Version appVersion;
+ private String appName;
+ private List<Content> appContents;
+ private List<ServiceDeclaration> importServices;
+ private List<ServiceDeclaration> exportServices;
+
+ /**
+ * create the applicationMetadata from appManifest
+ * @param appManifest the Application.mf manifest
+ */
+ public ApplicationMetadataImpl(Manifest appManifest) {
+
+ this.appContents = new ArrayList<Content>();
+ this.importServices = new ArrayList<ServiceDeclaration>();
+ this.exportServices = new ArrayList<ServiceDeclaration>();
+ setup(appManifest);
+
+ }
+
+ /**
+ * setup the application metadata from the appManifest
+ * @param appManifest application.mf manifest
+ */
+ private void setup(Manifest appManifest) {
+
+
+ Map<String, String> appMap = readManifestIntoMap(appManifest);
+
+ // configure the appSymbolicName and appVersion
+ this.appSymbolicName = appMap.get(AppConstants.APPLICATION_SYMBOLIC_NAME).trim();
+ this.appVersion = new Version(appMap.get(AppConstants.APPLICATION_VERSION).trim());
+ this.appName = appMap.get(AppConstants.APPLICATION_NAME);
+
+ if (this.appSymbolicName == null || this.appVersion == null) {
+ throw new IllegalArgumentException("Failed to create ApplicationMetadataImpl object from Manifest " + appManifest);
+ }
+
+ // configure appContents
+ String applicationContents = appMap.get(AppConstants.APPLICATION_CONTENT);
+ List<String> appContentsArray = ManifestProcessor.split(applicationContents, ",");
+ for (String content : appContentsArray) {
+ this.appContents.add(new ContentImpl(content));
+ }
+
+ // TODO: configure importServices + exportServices
+
+ }
+
+ /**
+ * Reads a manifest's main attributes into a String->String map.
+ * <p>
+ * Will always return a map, empty if the manifest had no attributes.
+ *
+ * @param mf The manifest to read.
+ * @return Map of manifest main attributes.
+ */
+ private Map<String, String> readManifestIntoMap(Manifest mf){
+ HashMap<String, String> props = new HashMap<String, String>();
+
+ Attributes mainAttrs = mf.getMainAttributes();
+ if (mainAttrs!=null){
+ Set<Entry<Object, Object>> attributeSet = mainAttrs.entrySet();
+ if (attributeSet != null){
+ // Copy all the manifest headers across. The entry set should be a set of
+ // Name to String mappings, by calling String.valueOf we do the conversion
+ // to a string and we do not NPE.
+ for (Map.Entry<Object, Object> entry : attributeSet) {
+ props.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
+ }
+ }
+ }
+
+ return props;
+ }
+
+ @Override
+ public List<Content> getApplicationContents()
+ {
+ return Collections.unmodifiableList(this.appContents);
+ }
+
+ @Override
+ public List<ServiceDeclaration> getApplicationExportServices()
+ {
+ return Collections.unmodifiableList(this.exportServices);
+ }
+
+ @Override
+ public List<ServiceDeclaration> getApplicationImportServices()
+ {
+ return Collections.unmodifiableList(this.importServices);
+ }
+
+ @Override
+ public String getApplicationSymbolicName()
+ {
+ return this.appSymbolicName;
+ }
+
+ @Override
+ public Version getApplicationVersion()
+ {
+ return this.appVersion;
+ }
+
+ @Override
+ public String getApplicationName() {
+ return this.appName;
+ }
+
+ @Override
+ public String getApplicationScope() {
+ return this.appSymbolicName + "_" + this.appVersion.toString();
+ }
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ApplicationMetadataImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ContentImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ContentImpl.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ContentImpl.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ContentImpl.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,135 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.api;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.ibm.websphere.application.aries.Content;
+import com.ibm.websphere.application.aries.VersionRange;
+
+
+/**
+ * Implementation of Content
+ *
+ */
+public class ContentImpl implements Content
+{
+ private String content;
+ private String contentName;
+ protected Map<String, String> attributes;
+ private Map<String, String> directives;
+
+ /**
+ *
+ * @param content Application-Content, Import-Package content
+ */
+ public ContentImpl(String content) {
+ this.content = content;
+ this.attributes = new HashMap<String, String>();
+ this.directives = new HashMap<String, String>();
+ setup(content, this.attributes, this.directives);
+ }
+
+ @Override
+ public String getContent() {
+ return this.content;
+ }
+
+ @Override
+ public String getContentName() {
+ return this.contentName;
+ }
+
+ @Override
+ public Map<String, String> getAttributes() {
+ return Collections.unmodifiableMap(this.attributes);
+ }
+
+ @Override
+ public Map<String, String> getDirectives() {
+ return Collections.unmodifiableMap(this.directives);
+ }
+
+ @Override
+ public String getAttribute(String key) {
+ String toReturn = this.attributes.get(key);
+ return toReturn;
+ }
+
+ /**
+ * add key value to the attributes map
+ * @param key
+ * @param value
+ */
+ public void addAttribute(String key, String value) {
+ this.attributes.put(key, value);
+ }
+
+ @Override
+ public String getDirective(String key) {
+ String toReturn = this.directives.get(key);
+ return toReturn;
+ }
+
+ /**
+ * add key value to the directives map
+ * @param key
+ * @param value
+ */
+ public void addDirective(String key, String value) {
+ this.directives.put(key, value);
+ }
+
+ @Override
+ public VersionRange getVersion() {
+ VersionRange vi = null;
+ if (this.attributes.get("version") != null && this.attributes.get("version").length() > 0) {
+ vi = new VersionRangeImpl(this.attributes.get("version"));
+ }
+ return vi;
+ }
+
+ /**
+ * setup attributes and directives from the Application-Content or Import-Package
+ * @param content
+ * @param attributes
+ * @param directives
+ */
+ protected void setup(String content, Map<String, String> attributes, Map<String, String> directives)
+ {
+ String[] tokens = content.split(";");
+ if (tokens.length < 1) {
+ throw new IllegalArgumentException("Invalid header split: " + content);
+ }
+ this.contentName = tokens[0].trim();
+ for (int i = 1; i < tokens.length; i++) {
+ int pos = tokens[i].indexOf('=');
+ if (pos != -1) {
+ if (pos > 0 && tokens[i].charAt(pos - 1) == ':') {
+ String name = tokens[i].substring(0, pos - 1).trim();
+ String value = tokens[i].substring(pos + 1).trim();
+ directives.put(name, trimDoubleQuotes(value));
+ } else {
+ String name = tokens[i].substring(0, pos).trim();
+ String value = tokens[i].substring(pos + 1).trim();
+ attributes.put(name, trimDoubleQuotes(value));
+ }
+ }
+ }
+ }
+
+ /**
+ * this method trims the double quotes at the beginning and end, for example version="1.0.0"
+ * @param value
+ * @return
+ */
+ private String trimDoubleQuotes(String value) {
+ if (value.startsWith("\"") && value.endsWith("\"")) {
+ value = value.substring(1, value.length() -1);
+ }
+ return value;
+ }
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ContentImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ServiceDeclarationImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ServiceDeclarationImpl.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ServiceDeclarationImpl.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ServiceDeclarationImpl.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.api;
+
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+import com.ibm.websphere.application.aries.Content;
+import com.ibm.websphere.application.aries.ServiceDeclaration;
+
+/**
+ * this class represents the Import-Services and Export-Services
+ * in the Application.mf file
+ *
+ */
+public class ServiceDeclarationImpl implements ServiceDeclaration
+{
+ private static final String FILTER = "filter";
+ private String interfaceName;
+ private Filter filter;
+
+ /**
+ * construct the ServiceDeclaration from the service string
+ * @param service the service string value of Import-Services or Export-Services header
+ * @throws InvalidSyntaxException
+ */
+ public ServiceDeclarationImpl(String service) throws InvalidSyntaxException
+ {
+ Content content = new ContentImpl(service);
+ this.interfaceName = content.getContentName();
+ String filterString = content.getAttribute(FILTER);
+ if (filterString != null) {
+ try {
+ this.filter = FrameworkUtil.createFilter(filterString);
+ } catch (InvalidSyntaxException ise) {
+ throw new InvalidSyntaxException("Failed to create filter for " + service, ise.getFilter(), ise.getCause());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.ServiceDeclaration#getInterfaceName()
+ */
+ public String getInterfaceName()
+ {
+ return this.interfaceName;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.ServiceDeclaration#getFilter()
+ */
+ public Filter getFilter()
+ {
+ return this.filter;
+ }
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ServiceDeclarationImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/VersionRangeImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/VersionRangeImpl.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/VersionRangeImpl.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/VersionRangeImpl.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,186 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.api;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.framework.Version;
+
+import com.ibm.websphere.application.aries.VersionRange;
+
+public class VersionRangeImpl implements VersionRange
+{
+ private String version;
+ /** The minimum desired version for the bundle */
+ private Version minimumVersion;
+ /** The maximum desired version for the bundle */
+ private Version maximumVersion;
+ /** True if the match is exclusive of the minimum version */
+ private boolean minimumExclusive;
+ /** True if the match is exclusive of the maximum version */
+ private boolean maximumExclusive;
+ /** exact version */
+ private boolean exactVersion;
+ /** A regexp to select the version */
+ private static final Pattern versionCapture = Pattern.compile("\"?(.*?)\"?$");
+
+ /**
+ *
+ * @param version version for the verioninfo
+ */
+ public VersionRangeImpl(String version) {
+ this.version = version;
+ this.exactVersion = false;
+ processVersionAttribute(this.version);
+ }
+
+ /**
+ *
+ * @param version version for the verioninfo
+ * @param exactVersion whether this is an exact version
+ */
+ public VersionRangeImpl(String version, boolean exactVersion) {
+ this.version = version;
+ this.exactVersion = exactVersion;
+ if (exactVersion) {
+ processExactVersionAttribute(this.version);
+ } else {
+ processVersionAttribute(this.version);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#toString()
+ */
+@Override
+ public String toString() {
+ return this.version;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#getExactVersion()
+ */
+ public Version getExactVersion() {
+ Version v = null;
+ if (this.exactVersion) {
+ v = getMinimumVersion();
+ }
+ return v;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#getMaximumVersion()
+ */
+ public Version getMaximumVersion()
+ {
+ return maximumVersion;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#getMinimumVersion()
+ */
+ public Version getMinimumVersion()
+ {
+ return minimumVersion;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#isMaximumExclusive()
+ */
+ public boolean isMaximumExclusive()
+ {
+ return maximumExclusive;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#isMaximumUnbounded()
+ */
+ public boolean isMaximumUnbounded()
+ {
+ boolean unbounded = maximumVersion == null;
+ return unbounded;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#isMinimumExclusive()
+ */
+ public boolean isMinimumExclusive()
+ {
+ return minimumExclusive;
+ }
+
+ /**
+ * this is designed for deployed-version as that is the exact version.
+ * @param version
+ * @return
+ * @throws IllegalArgumentException
+ */
+ private boolean processExactVersionAttribute(String version) throws IllegalArgumentException{
+ boolean success = processVersionAttribute(version);
+
+ if (maximumVersion == null) {
+ maximumVersion = minimumVersion;
+ }
+ if (!minimumVersion.equals(maximumVersion)) {
+ throw new IllegalArgumentException("Failed to parse " + version + " for the exact version. Could not parse " + version);
+ }
+
+ return success;
+ }
+ /**
+ * process the version attribute,
+ * @param version the value to be processed
+ * @return
+ * @throws IllegalArgumentException
+ */
+ private boolean processVersionAttribute(String version) throws IllegalArgumentException{
+ boolean success = false;
+
+ Matcher matches = versionCapture.matcher(version);
+
+ if (matches.matches()) {
+ String versions = matches.group(1);
+
+ if ((versions.startsWith("[") || versions.startsWith("(")) &&
+ (versions.endsWith("]") || versions.endsWith(")"))) {
+ if (versions.startsWith("[")) minimumExclusive = false;
+ else if (versions.startsWith("(")) minimumExclusive = true;
+
+ if (versions.endsWith("]")) maximumExclusive = false;
+ else if (versions.endsWith(")")) maximumExclusive = true;
+
+ int index = versions.indexOf(',');
+ String minVersion = versions.substring(1, index);
+ String maxVersion = versions.substring(index + 1, versions.length() - 1);
+
+ try {
+ minimumVersion = new Version(minVersion.trim());
+ maximumVersion = new Version(maxVersion.trim());
+ success = true;
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException("Failed to parse " + version + ". Could not parse " + versions, nfe);
+ }
+ } else {
+ try {
+ minimumVersion = new Version(versions.trim());
+ success = true;
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException("Failed to parse " + version + ". Could not parse " + versions, nfe);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Failed to parse " + version + ". Could not parse " + version);
+ }
+
+ return success;
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.ws.eba.app.api.VersionRange#isExactVersion()
+ */
+ public boolean isExactVersion() {
+ return this.exactVersion;
+ }
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/VersionRangeImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/AppConstants.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/AppConstants.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/AppConstants.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/AppConstants.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,31 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.utils;
+
+
+/**
+ * Constants for this bundle
+ */
+public interface AppConstants
+{
+ /** Trace group for this bundle */
+ public String TRACE_GROUP = "Aries.app.utils";
+
+ /** The application scope (used to find the applications bundle repository */
+ public static final String APPLICATION_SCOPE = "Application-Scope";
+ /** The application content directive for the application manifest */
+ public static final String APPLICATION_CONTENT = "Application-Content";
+ /** The application version directive for the application manifest */
+ public static final String APPLICATION_VERSION = "Application-Version";
+ /** The application name directive for the application manifest */
+ public static final String APPLICATION_NAME = "Application-Name";
+ /** The application symbolic name directive for the application manifest */
+ public static final String APPLICATION_SYMBOLIC_NAME = "Application-SymbolicName";
+ /** The default version for applications that do not have one */
+ public static final String DEFAULT_VERSION = "0.0.0";
+ /** The name of the application manifest in the application */
+ public static final String APPLICATION_MF = "META-INF/APPLICATION.MF";
+
+ public static final String MANIFEST_VERSION="1.0";
+}
\ No newline at end of file
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/AppConstants.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/ManifestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/ManifestProcessor.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/ManifestProcessor.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/ManifestProcessor.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,100 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.utils.manifest;
+
+import static com.ibm.ws.eba.app.utils.AppConstants.TRACE_GROUP;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+public class ManifestProcessor
+{
+ /**
+ * Reads a manifest's main attributes into a String->String map.
+ * <p>
+ * Will always return a map, empty if the manifest had no attributes.
+ *
+ * @param mf The manifest to read.
+ * @return Map of manifest main attributes.
+ */
+ public static Map<String, String> readManifestIntoMap(Manifest mf){
+
+ HashMap<String, String> props = new HashMap<String, String>();
+
+ Attributes mainAttrs = mf.getMainAttributes();
+ if (mainAttrs!=null){
+ Set<Entry<Object, Object>> attributeSet = mainAttrs.entrySet();
+ if (attributeSet != null){
+ // Copy all the manifest headers across. The entry set should be a set of
+ // Name to String mappings, by calling String.valueOf we do the conversion
+ // to a string and we do not NPE.
+ for (Map.Entry<Object, Object> entry : attributeSet) {
+ props.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
+ }
+ }
+ }
+
+ return props;
+ }
+
+ /**
+ *
+ * Splits a delimiter separated string, tolerating presence of non separator commas
+ * within double quoted segments.
+ *
+ * Eg.
+ * com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" &
+ * com.ibm.ws.eba.helloWorldService;version="1.0.0"
+ * com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)"
+ * com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"
+ * @param value the value to be split
+ * @param delimiter the delimiter string such as ',' etc.
+ * @return List<String> the components of the split String in a list
+ */
+ public static List<String> split(String value, String delimiter)
+ {
+
+ List<String> result = new ArrayList<String>();
+ if (value != null) {
+ String[] packages = value.split(delimiter);
+
+ for (int i = 0; i < packages.length; ) {
+ String tmp = packages[i++].trim();
+ // if there is a odd number of " in a string, we need to append
+ while (count(tmp, "\"") % 2 == 1) {
+ // check to see if we need to append the next package[i++]
+ tmp = tmp + delimiter + packages[i++].trim();
+ }
+
+ result.add(tmp);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * count the number of characters in a string
+ * @param parent The string to be searched
+ * @param subString The substring to be found
+ * @return the number of occurrence of the subString
+ */
+ private static int count(String parent, String subString) {
+
+ int count = 0 ;
+ int i = parent.indexOf(subString);
+ while (i > -1) {
+ if (parent.length() >= i+1)
+ parent = parent.substring(i+1);
+ count ++;
+ i = parent.indexOf(subString);
+ }
+ return count;
+ }
+}
\ No newline at end of file
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/ManifestProcessor.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/ManifestProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/ManifestProcessorTest.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/ManifestProcessorTest.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/ManifestProcessorTest.java Fri Oct 2 11:59:28 2009
@@ -0,0 +1,167 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.ws.eba.app.utils.test;
+
+import static com.ibm.ws.eba.app.utils.AppConstants.APPLICATION_MF;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Manifest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Version;
+
+import com.ibm.websphere.application.aries.ApplicationMetadata;
+import com.ibm.websphere.application.aries.ApplicationMetadataFactory;
+import com.ibm.websphere.application.aries.Content;
+import com.ibm.websphere.application.aries.VersionRange;
+import com.ibm.ws.eba.app.utils.manifest.ManifestProcessor;
+
+public class ManifestProcessorTest
+{
+
+ private static final String APP_FOLDER_NAME = "myAppFolder";
+ private static final String META_NAME = "META-INF";
+ private static final String SEP = ": ";
+
+ private static File appFolder = new File(APP_FOLDER_NAME);
+ private static File f = new File(appFolder, APPLICATION_MF);
+ private static File metaFolder = new File(appFolder,META_NAME);
+
+ private static Map<String,String> pairs = null;
+
+ @Before
+ public void setUp() throws Exception{
+
+ //clean up in case of a bad previous run
+ tearDown();
+
+ //enforce ordering of the keys
+ String[] keys = new String[]{
+ "Manifest-Version",
+ "Application-ManifestVersion",
+ "Application-Name",
+ "Application-SymbolicName",
+ "Application-Version",
+ "Application-Content",
+ "Export-Package",
+ "Import-Package",
+ "Application-Services"
+ };
+
+ String [] values = new String[]{
+ "1.0",
+ "1.0",
+ "Travel Reservation",
+ "com.travel.reservation",
+ "1.2",
+ "com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
+ "com.travel.reservation.api;version=1.2",
+ "com.travel.flight.api;version=\"[2.1.1,3.0.0)\",com.travel.rail.api;version=\"[1.0.0,2.0.0)\"",
+ "services.xml"
+ };
+
+ //the values of the manifest
+ //intentionally include a couple of long lines
+ pairs = new HashMap<String, String>();
+ int i = 0;
+ for (String key : keys){
+ pairs.put(key, values[i]);
+ i++;
+ }
+
+ appFolder.mkdir();
+ metaFolder.mkdir();
+ f.createNewFile();
+ PrintWriter pw = new PrintWriter(f);
+ //use write line for all but the last line
+ //count so we don't do the last line
+ i = 0;
+ for (String key : keys){
+ if (i < keys.length-1){
+ pw.println(key + SEP + pairs.get(key));
+ }
+ else{
+ //intentionally fail to print a new line at the end of the file
+ pw.print(key + SEP + pairs.get(key));
+ }
+ i++;
+ }
+ pw.write("\n\n");
+
+ //finish writing the file
+ pw.flush();
+ pw.close();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (f.exists()) f.delete();
+ if (metaFolder.exists()) metaFolder.delete();
+ if (appFolder.exists()) appFolder.delete();
+ }
+
+
+ /**
+ * Check a simple manifest can be read.
+ * @throws Exception
+ */
+ @Test
+ public void testSimpleManifest() throws Exception
+ {
+ Manifest mf = new Manifest(new FileInputStream(new File(appFolder,"/META-INF/APPLICATION.MF")));
+ Map<String, String> map = ManifestProcessor.readManifestIntoMap(mf);
+ assertNotNull(map);
+
+ //check all the expected keys and values
+ for (String key : pairs.keySet()){
+ assertTrue("Key: " + key + " was not found",map.containsKey(key));
+ String value = map.get(key);
+ assertNotNull("Value was not present for key: " + key ,value);
+ assertEquals("Value was not correct for key: " + key ,pairs.get(key),value);
+ }
+ //check there aren't any extra entries in the map that weren't expected
+ assertEquals("The maps did not match",pairs,map);
+ }
+
+ /**
+ * Check metadata can be extracted from a simple manifest.
+ */
+ @Test
+ public void testManifestMetadata() throws Exception
+ {
+ Manifest mf = new Manifest(new FileInputStream(new File(appFolder,"/META-INF/APPLICATION.MF")));
+ ApplicationMetadata am = ApplicationMetadataFactory.getApplicationMetadata(mf);
+ assertNotNull(am);
+
+ String appName = pairs.get("Application-Name");
+ assertEquals(am.getApplicationName(),appName);
+
+ //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
+ List<Content> contents = am.getApplicationContents();
+ for(Content content : contents){
+ if("com.travel.reservation.web".equals(content.getContentName())){
+ VersionRange vr = content.getVersion();
+ assertEquals(vr.getMinimumVersion(),new Version("1.1.0"));
+ assertEquals(vr.getMaximumVersion(),new Version("1.2.0"));
+ }else if("com.travel.reservation.business".equals(content.getContentName())){
+ VersionRange vr = content.getVersion();
+ assertNull(vr);
+ }else fail("Unexepcted content name " + content.getContentName());
+ }
+ }
+
+
+}
Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/ManifestProcessorTest.java
------------------------------------------------------------------------------
svn:executable = *
Modified: incubator/aries/contrib/ibm/prereqs/persistence/build.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/prereqs/persistence/build.xml?rev=820982&r1=820981&r2=820982&view=diff
==============================================================================
--- incubator/aries/contrib/ibm/prereqs/persistence/build.xml (original)
+++ incubator/aries/contrib/ibm/prereqs/persistence/build.xml Fri Oct 2 11:59:28 2009
@@ -2,8 +2,8 @@
<!-- (C) Copyright IBM Corp. 2009 -->
<project name="persistence" default="copy" basedir=".">
- <property name="file.name" value="persistence-api-1.0.jar"/>
- <property name="file.url" value="http://mirrors.ibiblio.org/pub/mirrors/maven2/javax/persistence/persistence-api/1.0/${file.name}"/>
+ <property name="file.name" value="geronimo-jpa_1.0_spec-1.1.2.jar"/>
+ <property name="file.url" value="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-jpa_1.0_spec/1.1.2/${file.name}"/>
<import file="../../build/imports/download.xml"/>
<property name="generated" value="${basedir}/generated"/>
@@ -51,4 +51,4 @@
</fileset>
</delete>
</target>
-</project>
\ No newline at end of file
+</project>
Modified: incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/ExceptionListener.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/ExceptionListener.java?rev=820982&r1=820981&r2=820982&view=diff
==============================================================================
--- incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/ExceptionListener.java (original)
+++ incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/ExceptionListener.java Fri Oct 2 11:59:28 2009
@@ -7,12 +7,6 @@
* <p>This class receives notification that an exception has been thrown from
* a mock object.
* </p>
- *
- * <p>SIB build component: sib.unittest.mediation</p>
- *
- * @author nottinga
- * @version 1.1
- * @since 1.0
*/
public interface ExceptionListener
{
@@ -25,4 +19,4 @@
* @param t the exception or error thrown.
*/
public void exceptionNotification(Throwable t);
-}
\ No newline at end of file
+}
Modified: incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/Skeleton.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/Skeleton.java?rev=820982&r1=820981&r2=820982&view=diff
==============================================================================
--- incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/Skeleton.java (original)
+++ incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/Skeleton.java Fri Oct 2 11:59:28 2009
@@ -65,12 +65,6 @@
* that interface will be returned, otherwise null will be returned.
* </li>
* </ol>
- *
- * <p>SIB build component: sib.unittest.mediation</p>
- *
- * @author nottinga
- * @version 1.20
- * @since 1.0
*/
public final class Skeleton implements InvocationHandler
{
@@ -1341,4 +1335,4 @@
return builder.toString();
}
-}
\ No newline at end of file
+}