You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ga...@apache.org on 2010/01/15 03:17:41 UTC
svn commit: r899518 [4/7] - in /incubator/aries/trunk/application: ./
application-api/ application-api/src/main/java/org/apache/aries/application/
application-api/src/main/java/org/apache/aries/application/filesystem/
application-api/src/main/java/org/...
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java Fri Jan 15 02:17:38 2010
@@ -1,106 +1,106 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.impl;
-
-import java.util.Map;
-
-import org.apache.aries.application.DeploymentContent;
-import org.apache.aries.application.VersionRange;
-import org.apache.aries.application.utils.AppConstants;
-import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
-import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
-import org.osgi.framework.Version;
-
-public final class DeploymentContentImpl implements DeploymentContent {
-
- private ContentImpl _content;
-
- /**
- * DeploymentContent relates to a bundle at a particular version.
- * We can therefore assume that the Version passed into this
- * constructor is the exact version in question.
- * @param bundleSymbolicName
- * @param version
- */
- public DeploymentContentImpl (String bundleSymbolicName, Version version) {
- NameValueMap<String, String> nvMap = new NameValueMap<String, String>();
- nvMap.put(AppConstants.DEPLOYMENT_BUNDLE_VERSION, version.toString());
- _content = new ContentImpl (bundleSymbolicName, nvMap);
- }
-
- /**
- * Construct a DeploymentContent from a string of the form,
- * bundle.symbolic.name;deployedContent="1.2.3"
- * @param deployedContent
- */
- public DeploymentContentImpl (String deployedContent) {
- _content = new ContentImpl (deployedContent);
- }
-
- public Version getExactVersion() {
- return getVersion().getExactVersion();
- }
-
- public String getAttribute(String key) {
- return _content.getAttribute(key);
- }
-
- public Map<String, String> getAttributes() {
- return _content.getAttributes();
- }
-
- public String getContentName() {
- return _content.getContentName();
- }
-
- public String getDirective(String key) {
- return _content.getDirective(key);
- }
-
- public Map<String, String> getDirectives() {
- return _content.getDirectives();
- }
-
- public VersionRange getVersion() {
- String deployedVersion = _content.getAttribute(AppConstants.DEPLOYMENT_BUNDLE_VERSION);
- VersionRange vr = null;
- if (deployedVersion != null && deployedVersion.length() > 0) {
- vr = ManifestHeaderProcessor.parseVersionRange(deployedVersion, true);
- }
- return vr;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == null)
- return false;
- if (this == other)
- return true;
- if (other instanceof DeploymentContentImpl) {
- return _content.equals(((DeploymentContentImpl) other)._content);
- } else {
- return false;
- }
- }
-
- public Map<String, String> getNameValueMap() {
- return _content.getNameValueMap();
- }
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.impl;
+
+import java.util.Map;
+
+import org.apache.aries.application.DeploymentContent;
+import org.apache.aries.application.VersionRange;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
+import org.osgi.framework.Version;
+
+public final class DeploymentContentImpl implements DeploymentContent {
+
+ private ContentImpl _content;
+
+ /**
+ * DeploymentContent relates to a bundle at a particular version.
+ * We can therefore assume that the Version passed into this
+ * constructor is the exact version in question.
+ * @param bundleSymbolicName
+ * @param version
+ */
+ public DeploymentContentImpl (String bundleSymbolicName, Version version) {
+ NameValueMap<String, String> nvMap = new NameValueMap<String, String>();
+ nvMap.put(AppConstants.DEPLOYMENT_BUNDLE_VERSION, version.toString());
+ _content = new ContentImpl (bundleSymbolicName, nvMap);
+ }
+
+ /**
+ * Construct a DeploymentContent from a string of the form,
+ * bundle.symbolic.name;deployedContent="1.2.3"
+ * @param deployedContent
+ */
+ public DeploymentContentImpl (String deployedContent) {
+ _content = new ContentImpl (deployedContent);
+ }
+
+ public Version getExactVersion() {
+ return getVersion().getExactVersion();
+ }
+
+ public String getAttribute(String key) {
+ return _content.getAttribute(key);
+ }
+
+ public Map<String, String> getAttributes() {
+ return _content.getAttributes();
+ }
+
+ public String getContentName() {
+ return _content.getContentName();
+ }
+
+ public String getDirective(String key) {
+ return _content.getDirective(key);
+ }
+
+ public Map<String, String> getDirectives() {
+ return _content.getDirectives();
+ }
+
+ public VersionRange getVersion() {
+ String deployedVersion = _content.getAttribute(AppConstants.DEPLOYMENT_BUNDLE_VERSION);
+ VersionRange vr = null;
+ if (deployedVersion != null && deployedVersion.length() > 0) {
+ vr = ManifestHeaderProcessor.parseVersionRange(deployedVersion, true);
+ }
+ return vr;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null)
+ return false;
+ if (this == other)
+ return true;
+ if (other instanceof DeploymentContentImpl) {
+ return _content.equals(((DeploymentContentImpl) other)._content);
+ } else {
+ return false;
+ }
+ }
+
+ public Map<String, String> getNameValueMap() {
+ return _content.getNameValueMap();
+ }
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentContentImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java Fri Jan 15 02:17:38 2010
@@ -1,41 +1,41 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.impl;
-
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.aries.application.DeploymentMetadata;
-import org.apache.aries.application.DeploymentMetadataFactory;
-import org.apache.aries.application.filesystem.IFile;
-import org.apache.aries.application.management.AriesApplication;
-import org.apache.aries.application.management.BundleInfo;
-
-public class DeploymentMetadataFactoryImpl implements DeploymentMetadataFactory {
-
- public DeploymentMetadata createDeploymentMetadata(AriesApplication app,
- Set<BundleInfo> additionalBundlesRequired) {
- return new DeploymentMetadataImpl (app, additionalBundlesRequired);
- }
-
- public DeploymentMetadata createDeploymentMetadata(IFile src) throws IOException {
- return new DeploymentMetadataImpl (src);
- }
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.impl;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.DeploymentMetadataFactory;
+import org.apache.aries.application.filesystem.IFile;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.BundleInfo;
+
+public class DeploymentMetadataFactoryImpl implements DeploymentMetadataFactory {
+
+ public DeploymentMetadata createDeploymentMetadata(AriesApplication app,
+ Set<BundleInfo> additionalBundlesRequired) {
+ return new DeploymentMetadataImpl (app, additionalBundlesRequired);
+ }
+
+ public DeploymentMetadata createDeploymentMetadata(IFile src) throws IOException {
+ return new DeploymentMetadataImpl (src);
+ }
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java Fri Jan 15 02:17:38 2010
@@ -1,141 +1,141 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.impl;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.apache.aries.application.ApplicationMetadata;
-import org.apache.aries.application.Content;
-import org.apache.aries.application.DeploymentContent;
-import org.apache.aries.application.DeploymentMetadata;
-import org.apache.aries.application.filesystem.IFile;
-import org.apache.aries.application.management.AriesApplication;
-import org.apache.aries.application.management.BundleInfo;
-import org.apache.aries.application.utils.AppConstants;
-import org.apache.aries.application.utils.manifest.ManifestProcessor;
-import org.osgi.framework.Version;
-
-public class DeploymentMetadataImpl implements DeploymentMetadata {
-
- ApplicationMetadata _applicationMetadata;
- List<DeploymentContent> _deploymentContent;
-
- public DeploymentMetadataImpl (AriesApplication app, Set<BundleInfo> additionalBundlesRequired) {
- _applicationMetadata = app.getApplicationMetadata();
- _deploymentContent = new ArrayList<DeploymentContent>();
-
- // DeploymentContent needs to list everything in the application content
- // plus all the bundles in additonalBundlesRequired
- for (Content c: _applicationMetadata.getApplicationContents()) {
- _deploymentContent.add(new DeploymentContentImpl(c.getContentName(), c.getVersion().getMinimumVersion()));
- }
- for (BundleInfo bundleInfo : additionalBundlesRequired) {
- DeploymentContentImpl dci = new DeploymentContentImpl(bundleInfo.getSymbolicName(),
- bundleInfo.getVersion());
- _deploymentContent.add(dci);
- }
- }
-
- /**
- * Construct a DeploymentMetadata from an IFile
- * @param src
- * @throws IOException
- */
- public DeploymentMetadataImpl (IFile src) throws IOException {
- InputStream is = src.open();
- try {
- // Populate application symbolic name and version fields
- Manifest mf = ManifestProcessor.parseManifest(is);
- _applicationMetadata = new ApplicationMetadataImpl (mf);
-
- Attributes attributes = mf.getMainAttributes();
- String deploymentContent = attributes.getValue(AppConstants.DEPLOYMENT_CONTENT);
- List<String> dcList = ManifestProcessor.split(deploymentContent, ",");
- _deploymentContent = new ArrayList<DeploymentContent>();
- for (String s : dcList) {
- _deploymentContent.add(new DeploymentContentImpl(s));
- }
- } finally {
- is.close();
- }
- }
-
- public List<DeploymentContent> getApplicationDeploymentContents() {
- return Collections.unmodifiableList(_deploymentContent);
- }
-
- public ApplicationMetadata getApplicationMetadata() {
- return _applicationMetadata;
- }
-
- public String getApplicationSymbolicName() {
- return _applicationMetadata.getApplicationSymbolicName();
- }
-
- public Version getApplicationVersion() {
- return _applicationMetadata.getApplicationVersion();
- }
-
-
- public void store(File f) throws FileNotFoundException, IOException{
- FileOutputStream fos = new FileOutputStream (f);
- store(fos);
- fos.close();
- }
-
- public void store(OutputStream out) throws IOException {
- // We weren't built from a Manifest, so construct one.
- Manifest mf = new Manifest();
- Attributes attributes = mf.getMainAttributes();
- attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), AppConstants.MANIFEST_VERSION);
- attributes.putValue(AppConstants.APPLICATION_VERSION, getApplicationVersion().toString());
- attributes.putValue(AppConstants.APPLICATION_SYMBOLIC_NAME, getApplicationSymbolicName());
- attributes.putValue(AppConstants.DEPLOYMENT_CONTENT, getDeploymentContentsAsString());
- mf.write(out);
- }
-
-
-
- private String getDeploymentContentsAsString () {
- StringBuilder builder = new StringBuilder();
- for (DeploymentContent dc : getApplicationDeploymentContents()) {
- builder.append(dc.getContentName());
- builder.append(';' + AppConstants.DEPLOYMENT_BUNDLE_VERSION + "=");
- builder.append(dc.getExactVersion());
- builder.append(",");
- }
- if (builder.length() > 0) {
- builder.deleteCharAt(builder.length() - 1);
- }
- return builder.toString();
- }
-
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.Content;
+import org.apache.aries.application.DeploymentContent;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.filesystem.IFile;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.Version;
+
+public class DeploymentMetadataImpl implements DeploymentMetadata {
+
+ ApplicationMetadata _applicationMetadata;
+ List<DeploymentContent> _deploymentContent;
+
+ public DeploymentMetadataImpl (AriesApplication app, Set<BundleInfo> additionalBundlesRequired) {
+ _applicationMetadata = app.getApplicationMetadata();
+ _deploymentContent = new ArrayList<DeploymentContent>();
+
+ // DeploymentContent needs to list everything in the application content
+ // plus all the bundles in additonalBundlesRequired
+ for (Content c: _applicationMetadata.getApplicationContents()) {
+ _deploymentContent.add(new DeploymentContentImpl(c.getContentName(), c.getVersion().getMinimumVersion()));
+ }
+ for (BundleInfo bundleInfo : additionalBundlesRequired) {
+ DeploymentContentImpl dci = new DeploymentContentImpl(bundleInfo.getSymbolicName(),
+ bundleInfo.getVersion());
+ _deploymentContent.add(dci);
+ }
+ }
+
+ /**
+ * Construct a DeploymentMetadata from an IFile
+ * @param src
+ * @throws IOException
+ */
+ public DeploymentMetadataImpl (IFile src) throws IOException {
+ InputStream is = src.open();
+ try {
+ // Populate application symbolic name and version fields
+ Manifest mf = ManifestProcessor.parseManifest(is);
+ _applicationMetadata = new ApplicationMetadataImpl (mf);
+
+ Attributes attributes = mf.getMainAttributes();
+ String deploymentContent = attributes.getValue(AppConstants.DEPLOYMENT_CONTENT);
+ List<String> dcList = ManifestProcessor.split(deploymentContent, ",");
+ _deploymentContent = new ArrayList<DeploymentContent>();
+ for (String s : dcList) {
+ _deploymentContent.add(new DeploymentContentImpl(s));
+ }
+ } finally {
+ is.close();
+ }
+ }
+
+ public List<DeploymentContent> getApplicationDeploymentContents() {
+ return Collections.unmodifiableList(_deploymentContent);
+ }
+
+ public ApplicationMetadata getApplicationMetadata() {
+ return _applicationMetadata;
+ }
+
+ public String getApplicationSymbolicName() {
+ return _applicationMetadata.getApplicationSymbolicName();
+ }
+
+ public Version getApplicationVersion() {
+ return _applicationMetadata.getApplicationVersion();
+ }
+
+
+ public void store(File f) throws FileNotFoundException, IOException{
+ FileOutputStream fos = new FileOutputStream (f);
+ store(fos);
+ fos.close();
+ }
+
+ public void store(OutputStream out) throws IOException {
+ // We weren't built from a Manifest, so construct one.
+ Manifest mf = new Manifest();
+ Attributes attributes = mf.getMainAttributes();
+ attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), AppConstants.MANIFEST_VERSION);
+ attributes.putValue(AppConstants.APPLICATION_VERSION, getApplicationVersion().toString());
+ attributes.putValue(AppConstants.APPLICATION_SYMBOLIC_NAME, getApplicationSymbolicName());
+ attributes.putValue(AppConstants.DEPLOYMENT_CONTENT, getDeploymentContentsAsString());
+ mf.write(out);
+ }
+
+
+
+ private String getDeploymentContentsAsString () {
+ StringBuilder builder = new StringBuilder();
+ for (DeploymentContent dc : getApplicationDeploymentContents()) {
+ builder.append(dc.getContentName());
+ builder.append(';' + AppConstants.DEPLOYMENT_BUNDLE_VERSION + "=");
+ builder.append(dc.getExactVersion());
+ builder.append(",");
+ }
+ if (builder.length() > 0) {
+ builder.deleteCharAt(builder.length() - 1);
+ }
+ return builder.toString();
+ }
+
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java Fri Jan 15 02:17:38 2010
@@ -1,73 +1,73 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.impl;
-
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-
-import org.apache.aries.application.Content;
-import org.apache.aries.application.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 A single service string value from the 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 org.apache.aries.application.impl.ServiceDeclaration#getInterfaceName()
- */
- public String getInterfaceName()
- {
- return this.interfaceName;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.ServiceDeclaration#getFilter()
- */
- public Filter getFilter()
- {
- return this.filter;
- }
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.impl;
+
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+import org.apache.aries.application.Content;
+import org.apache.aries.application.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 A single service string value from the 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 org.apache.aries.application.impl.ServiceDeclaration#getInterfaceName()
+ */
+ public String getInterfaceName()
+ {
+ return this.interfaceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.ServiceDeclaration#getFilter()
+ */
+ public Filter getFilter()
+ {
+ return this.filter;
+ }
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
('svn:executable' removed)
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java Fri Jan 15 02:17:38 2010
@@ -1,236 +1,236 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.impl;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.osgi.framework.Version;
-
-import org.apache.aries.application.VersionRange;
-import org.apache.aries.application.utils.internal.MessageUtil;
-
-public final 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;
- /** 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;
- 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;
- if (exactVersion) {
- processExactVersionAttribute(this.version);
- } else {
- processVersionAttribute(this.version);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#toString()
- */
- @Override
- public String toString() {
- return this.version;
- }
-
- public int hashCode()
- {
- return version.hashCode();
- }
-
- public boolean equals(Object other)
- {
- if (other == this) return true;
- if (other == null) return false;
-
- if (other instanceof VersionRangeImpl) {
- return version.equals(((VersionRangeImpl)other).version);
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#getExactVersion()
- */
- public Version getExactVersion() {
- Version v = null;
- if (isExactVersion()) {
- v = getMinimumVersion();
- }
- return v;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#getMaximumVersion()
- */
- public Version getMaximumVersion()
- {
- return maximumVersion;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#getMinimumVersion()
- */
- public Version getMinimumVersion()
- {
- return minimumVersion;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#isMaximumExclusive()
- */
- public boolean isMaximumExclusive()
- {
- return maximumExclusive;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#isMaximumUnbounded()
- */
- public boolean isMaximumUnbounded()
- {
- boolean unbounded = maximumVersion == null;
- return unbounded;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.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(MessageUtil.getMessage("APPUTILS0011E", version));
- }
-
- if (!!!isExactVersion()) {
- throw new IllegalArgumentException(MessageUtil.getMessage("APPUTILS0009E", 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(MessageUtil.getMessage("APPUTILS0009E", version), nfe);
- }
- } else {
- try {
- if (versions.trim().length() == 0) minimumVersion = new Version(0,0,0);
- else minimumVersion = new Version(versions.trim());
- success = true;
- } catch (NumberFormatException nfe) {
- throw new IllegalArgumentException(MessageUtil.getMessage("APPUTILS0009E", version), nfe);
- }
- }
- } else {
- throw new IllegalArgumentException(MessageUtil.getMessage("APPUTILS0009E", version));
- }
-
- return success;
- }
-
- public boolean matches(Version version)
- {
- boolean result;
- if (this.getMaximumVersion() == null) {
- result = this.getMinimumVersion().compareTo(version) <= 0;
- } else {
- int minN = this.isMinimumExclusive() ? 0 : 1;
- int maxN = this.isMaximumExclusive() ? 0 : 1;
-
- result = (this.getMinimumVersion().compareTo(version) < minN) &&
- (version.compareTo(this.getMaximumVersion()) < maxN);
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.apache.aries.application.impl.VersionRange#isExactVersion()
- */
- public boolean isExactVersion() {
- return minimumVersion.equals(maximumVersion) && minimumExclusive == maximumExclusive && !!!minimumExclusive;
- }
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.impl;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.framework.Version;
+
+import org.apache.aries.application.VersionRange;
+import org.apache.aries.application.utils.internal.MessageUtil;
+
+public final 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;
+ /** 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;
+ 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;
+ if (exactVersion) {
+ processExactVersionAttribute(this.version);
+ } else {
+ processVersionAttribute(this.version);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#toString()
+ */
+ @Override
+ public String toString() {
+ return this.version;
+ }
+
+ public int hashCode()
+ {
+ return version.hashCode();
+ }
+
+ public boolean equals(Object other)
+ {
+ if (other == this) return true;
+ if (other == null) return false;
+
+ if (other instanceof VersionRangeImpl) {
+ return version.equals(((VersionRangeImpl)other).version);
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#getExactVersion()
+ */
+ public Version getExactVersion() {
+ Version v = null;
+ if (isExactVersion()) {
+ v = getMinimumVersion();
+ }
+ return v;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#getMaximumVersion()
+ */
+ public Version getMaximumVersion()
+ {
+ return maximumVersion;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#getMinimumVersion()
+ */
+ public Version getMinimumVersion()
+ {
+ return minimumVersion;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#isMaximumExclusive()
+ */
+ public boolean isMaximumExclusive()
+ {
+ return maximumExclusive;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#isMaximumUnbounded()
+ */
+ public boolean isMaximumUnbounded()
+ {
+ boolean unbounded = maximumVersion == null;
+ return unbounded;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.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(MessageUtil.getMessage("APPUTILS0011E", version));
+ }
+
+ if (!!!isExactVersion()) {
+ throw new IllegalArgumentException(MessageUtil.getMessage("APPUTILS0009E", 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(MessageUtil.getMessage("APPUTILS0009E", version), nfe);
+ }
+ } else {
+ try {
+ if (versions.trim().length() == 0) minimumVersion = new Version(0,0,0);
+ else minimumVersion = new Version(versions.trim());
+ success = true;
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException(MessageUtil.getMessage("APPUTILS0009E", version), nfe);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException(MessageUtil.getMessage("APPUTILS0009E", version));
+ }
+
+ return success;
+ }
+
+ public boolean matches(Version version)
+ {
+ boolean result;
+ if (this.getMaximumVersion() == null) {
+ result = this.getMinimumVersion().compareTo(version) <= 0;
+ } else {
+ int minN = this.isMinimumExclusive() ? 0 : 1;
+ int maxN = this.isMaximumExclusive() ? 0 : 1;
+
+ result = (this.getMinimumVersion().compareTo(version) < minN) &&
+ (version.compareTo(this.getMaximumVersion()) < maxN);
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.aries.application.impl.VersionRange#isExactVersion()
+ */
+ public boolean isExactVersion() {
+ return minimumVersion.equals(maximumVersion) && minimumExclusive == maximumExclusive && !!!minimumExclusive;
+ }
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
('svn:executable' removed)
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/VersionRangeImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
('svn:executable' removed)
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java Fri Jan 15 02:17:38 2010
@@ -1,67 +1,67 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.utils.filesystem;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import org.apache.aries.application.filesystem.IDirectory;
-import org.apache.aries.application.utils.filesystem.impl.DirectoryImpl;
-import org.apache.aries.application.utils.filesystem.impl.ZipDirectory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An abstraction of a file system. A file system can be a zip, or a directory.
- */
-public class FileSystem {
-
- private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.utils");
-
- /**
- * This method gets the IDirectory that represents the root of a virtual file
- * system. The provided file can either identify a directory, or a zip file.
- *
- * @param fs the zip file.
- * @return the root of the virtual FS.
- */
- public static IDirectory getFSRoot(File fs)
- {
- IDirectory dir = null;
-
- if (fs.exists()) {
- if (fs.isDirectory()) {
- dir = new DirectoryImpl(fs, fs);
- } else if (fs.isFile()) {
- try {
- dir = new ZipDirectory(fs, fs);
- } catch (IOException e) {
- _logger.error ("IOException in IDirectory.getFSRoot", e);
- }
- }
- }
- else {
- // since this method does not throw an exception but just returns null, make sure we do not lose the error
- _logger.error("File not found in IDirectory.getFSRoot", new FileNotFoundException(fs.getPath()));
- }
- return dir;
- }
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.utils.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.utils.filesystem.impl.DirectoryImpl;
+import org.apache.aries.application.utils.filesystem.impl.ZipDirectory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An abstraction of a file system. A file system can be a zip, or a directory.
+ */
+public class FileSystem {
+
+ private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.utils");
+
+ /**
+ * This method gets the IDirectory that represents the root of a virtual file
+ * system. The provided file can either identify a directory, or a zip file.
+ *
+ * @param fs the zip file.
+ * @return the root of the virtual FS.
+ */
+ public static IDirectory getFSRoot(File fs)
+ {
+ IDirectory dir = null;
+
+ if (fs.exists()) {
+ if (fs.isDirectory()) {
+ dir = new DirectoryImpl(fs, fs);
+ } else if (fs.isFile()) {
+ try {
+ dir = new ZipDirectory(fs, fs);
+ } catch (IOException e) {
+ _logger.error ("IOException in IDirectory.getFSRoot", e);
+ }
+ }
+ }
+ else {
+ // since this method does not throw an exception but just returns null, make sure we do not lose the error
+ _logger.error("File not found in IDirectory.getFSRoot", new FileNotFoundException(fs.getPath()));
+ }
+ return dir;
+ }
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/FileSystem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java Fri Jan 15 02:17:38 2010
@@ -1,205 +1,205 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.utils.filesystem;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.apache.aries.application.utils.internal.MessageUtil;
-
-public class IOUtils
-{
- /**
- * Copy an InputStream to an OutputStream and close the InputStream afterwards.
- */
- public static void copy(InputStream in, OutputStream out) throws IOException
- {
- try {
- int len;
- byte[] b = new byte[1024];
- while ((len = in.read(b)) != -1)
- out.write(b,0,len);
- }
- finally {
- close(in);
- }
- }
-
- /**
- * Close some xStream for good :)
- */
- public static void close(Closeable c)
- {
- try {
- if (c != null)
- c.close();
- }
- catch (IOException e) { c=null; } //in other words do nothing in a language findbugs can understand
- }
-
- public static OutputStream getOutputStream(File outputDir, String relativePath) throws IOException
- {
- int lastSeparatorIndex = relativePath.replace(File.separatorChar,'/').lastIndexOf("/");
- String dirName = null;
- String fileName = null;
-
- File outputDirectory;
- if (lastSeparatorIndex != -1)
- {
- dirName = relativePath.substring(0, lastSeparatorIndex);
- fileName = relativePath.substring(lastSeparatorIndex + 1);
-
- outputDirectory = new File(outputDir, dirName);
-
- if (!!!outputDirectory.exists() && !!!outputDirectory.mkdirs())
- throw new IOException(MessageUtil.getMessage("APPUTILS0012E", relativePath));
- }
- else
- {
- outputDirectory = outputDir;
- fileName = relativePath;
- }
-
- File outputFile = new File(outputDirectory, fileName);
- return new FileOutputStream(outputFile);
- }
-
- /**
- * Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.
- * Necessary subdirectories will be created. This method will close the supplied InputStream.
- */
- public static void writeOut(File outputDir, String relativePath, InputStream content) throws IOException
- {
- OutputStream out = null;
- try {
- out = getOutputStream(outputDir, relativePath);
- IOUtils.copy(content, out);
- }
- finally {
- close(out);
- }
- }
-
- /**
- * Zip up all contents of rootDir (recursively) into targetStream
- */
- @SuppressWarnings("unchecked")
- public static void zipUp (File rootDir, OutputStream targetStream) throws IOException
- {
- ZipOutputStream out = null;
- try {
- out = new ZipOutputStream (targetStream);
- zipUpRecursive(out, "", rootDir, (Set<String>) Collections.EMPTY_SET);
- } finally {
- close(out);
- }
- }
-
- /**
- * Zip up all contents of rootDir (recursively) into targetFile
- */
- public static void zipUp(File rootDir, File targetFile) throws IOException
- {
- zipUp (rootDir, new FileOutputStream (targetFile));
- }
-
- /**
- * Jar up all the contents of rootDir (recursively) into targetFile and add the manifest
- */
- public static void jarUp(File rootDir, File targetFile, Manifest manifest) throws IOException
- {
- JarOutputStream out = null;
- try {
- out = new JarOutputStream(new FileOutputStream(targetFile), manifest);
- zipUpRecursive(out, "", rootDir, new HashSet<String>(Arrays.asList("META-INF/MANIFEST.MF")));
- }
- finally {
- close(out);
- }
- }
-
- /**
- * Helper method used by zipUp
- */
- private static void zipUpRecursive(ZipOutputStream out, String prefix,
- File directory, Set<String> filesToExclude) throws IOException
- {
- File[] files = directory.listFiles();
- if (files != null)
- {
- for (File f : files)
- {
- String fileName;
- if (f.isDirectory())
- fileName = prefix + f.getName() + "/";
- else
- fileName = prefix + f.getName();
-
- if (filesToExclude.contains(fileName))
- continue;
-
- ZipEntry ze = new ZipEntry(fileName);
- ze.setSize(f.length());
- ze.setTime(f.lastModified());
- out.putNextEntry(ze);
-
- if (f.isDirectory())
- zipUpRecursive(out, fileName, f, filesToExclude);
- else
- {
- IOUtils.copy(new FileInputStream(f), out);
- }
- }
- }
- }
-
- /**
- * Do rm -rf
- */
- public static boolean deleteRecursive(File root)
- {
- if (!!!root.exists())
- return false;
- else if (root.isFile())
- return root.delete();
- else {
- boolean result = true;
- for (File f : root.listFiles())
- {
- result = deleteRecursive(f) && result;
- }
- return root.delete() && result;
- }
- }
-}
-
+/*
+ * 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 WARRANTIESOR 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.aries.application.utils.filesystem;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.aries.application.utils.internal.MessageUtil;
+
+public class IOUtils
+{
+ /**
+ * Copy an InputStream to an OutputStream and close the InputStream afterwards.
+ */
+ public static void copy(InputStream in, OutputStream out) throws IOException
+ {
+ try {
+ int len;
+ byte[] b = new byte[1024];
+ while ((len = in.read(b)) != -1)
+ out.write(b,0,len);
+ }
+ finally {
+ close(in);
+ }
+ }
+
+ /**
+ * Close some xStream for good :)
+ */
+ public static void close(Closeable c)
+ {
+ try {
+ if (c != null)
+ c.close();
+ }
+ catch (IOException e) { c=null; } //in other words do nothing in a language findbugs can understand
+ }
+
+ public static OutputStream getOutputStream(File outputDir, String relativePath) throws IOException
+ {
+ int lastSeparatorIndex = relativePath.replace(File.separatorChar,'/').lastIndexOf("/");
+ String dirName = null;
+ String fileName = null;
+
+ File outputDirectory;
+ if (lastSeparatorIndex != -1)
+ {
+ dirName = relativePath.substring(0, lastSeparatorIndex);
+ fileName = relativePath.substring(lastSeparatorIndex + 1);
+
+ outputDirectory = new File(outputDir, dirName);
+
+ if (!!!outputDirectory.exists() && !!!outputDirectory.mkdirs())
+ throw new IOException(MessageUtil.getMessage("APPUTILS0012E", relativePath));
+ }
+ else
+ {
+ outputDirectory = outputDir;
+ fileName = relativePath;
+ }
+
+ File outputFile = new File(outputDirectory, fileName);
+ return new FileOutputStream(outputFile);
+ }
+
+ /**
+ * Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.
+ * Necessary subdirectories will be created. This method will close the supplied InputStream.
+ */
+ public static void writeOut(File outputDir, String relativePath, InputStream content) throws IOException
+ {
+ OutputStream out = null;
+ try {
+ out = getOutputStream(outputDir, relativePath);
+ IOUtils.copy(content, out);
+ }
+ finally {
+ close(out);
+ }
+ }
+
+ /**
+ * Zip up all contents of rootDir (recursively) into targetStream
+ */
+ @SuppressWarnings("unchecked")
+ public static void zipUp (File rootDir, OutputStream targetStream) throws IOException
+ {
+ ZipOutputStream out = null;
+ try {
+ out = new ZipOutputStream (targetStream);
+ zipUpRecursive(out, "", rootDir, (Set<String>) Collections.EMPTY_SET);
+ } finally {
+ close(out);
+ }
+ }
+
+ /**
+ * Zip up all contents of rootDir (recursively) into targetFile
+ */
+ public static void zipUp(File rootDir, File targetFile) throws IOException
+ {
+ zipUp (rootDir, new FileOutputStream (targetFile));
+ }
+
+ /**
+ * Jar up all the contents of rootDir (recursively) into targetFile and add the manifest
+ */
+ public static void jarUp(File rootDir, File targetFile, Manifest manifest) throws IOException
+ {
+ JarOutputStream out = null;
+ try {
+ out = new JarOutputStream(new FileOutputStream(targetFile), manifest);
+ zipUpRecursive(out, "", rootDir, new HashSet<String>(Arrays.asList("META-INF/MANIFEST.MF")));
+ }
+ finally {
+ close(out);
+ }
+ }
+
+ /**
+ * Helper method used by zipUp
+ */
+ private static void zipUpRecursive(ZipOutputStream out, String prefix,
+ File directory, Set<String> filesToExclude) throws IOException
+ {
+ File[] files = directory.listFiles();
+ if (files != null)
+ {
+ for (File f : files)
+ {
+ String fileName;
+ if (f.isDirectory())
+ fileName = prefix + f.getName() + "/";
+ else
+ fileName = prefix + f.getName();
+
+ if (filesToExclude.contains(fileName))
+ continue;
+
+ ZipEntry ze = new ZipEntry(fileName);
+ ze.setSize(f.length());
+ ze.setTime(f.lastModified());
+ out.putNextEntry(ze);
+
+ if (f.isDirectory())
+ zipUpRecursive(out, fileName, f, filesToExclude);
+ else
+ {
+ IOUtils.copy(new FileInputStream(f), out);
+ }
+ }
+ }
+ }
+
+ /**
+ * Do rm -rf
+ */
+ public static boolean deleteRecursive(File root)
+ {
+ if (!!!root.exists())
+ return false;
+ else if (root.isFile())
+ return root.delete();
+ else {
+ boolean result = true;
+ for (File f : root.listFiles())
+ {
+ result = deleteRecursive(f) && result;
+ }
+ return root.delete() && result;
+ }
+ }
+}
+
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java Fri Jan 15 02:17:38 2010
@@ -1,116 +1,116 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.utils.filesystem.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.aries.application.filesystem.IDirectory;
-import org.apache.aries.application.filesystem.IFile;
-import org.apache.aries.application.utils.AppConstants;
-
-/**
- * An IDirectory representing a java.io.File whose isDirectory method returns true.
- */
-public class DirectoryImpl extends FileImpl implements IDirectory
-{
- /**
- * @param dir the file to represent.
- * @param rootFile the file that represents the FS root.
- */
- public DirectoryImpl(File dir, File rootFile)
- {
- super(dir, rootFile);
- }
-
- public IFile getFile(String name)
- {
- File desiredFile = new File(file, name);
- IFile result = null;
-
- if (desiredFile.exists()) {
- result = new FileImpl(desiredFile, rootDirFile);
- }
- return result;
- }
-
- public boolean isRoot()
- {
- boolean result = (rootDirFile == file);
- return result;
- }
-
- public List<IFile> listFiles()
- {
- List<IFile> files = new ArrayList<IFile>();
- File[] filesInDir = file.listFiles();
- if (filesInDir != null) {
- for (File f : filesInDir) {
- if (f.isFile()) {
- files.add(new FileImpl(f, rootDirFile));
- } else if (f.isDirectory()) {
- files.add(new DirectoryImpl(f, rootDirFile));
- }
- }
- }
- return files;
- }
-
- public Iterator<IFile> iterator()
- {
- Iterator<IFile> result = listFiles().iterator();
- return result;
- }
-
- @Override
- public IDirectory getParent()
- {
- IDirectory result = isRoot() ? null : super.getParent();
- return result;
- }
-
- @Override
- public IDirectory convert()
- {
- return this;
- }
-
- @Override
- public InputStream open() throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getLastModified()
- {
- long result = super.getLastModified();
- for (IFile aFile : this) {
- long tmpLastModified = aFile.getLastModified();
-
- if (tmpLastModified > result) result = tmpLastModified;
- }
- return result;
- }
-}
+/*
+ * 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 WARRANTIESOR 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.aries.application.utils.filesystem.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.filesystem.IFile;
+import org.apache.aries.application.utils.AppConstants;
+
+/**
+ * An IDirectory representing a java.io.File whose isDirectory method returns true.
+ */
+public class DirectoryImpl extends FileImpl implements IDirectory
+{
+ /**
+ * @param dir the file to represent.
+ * @param rootFile the file that represents the FS root.
+ */
+ public DirectoryImpl(File dir, File rootFile)
+ {
+ super(dir, rootFile);
+ }
+
+ public IFile getFile(String name)
+ {
+ File desiredFile = new File(file, name);
+ IFile result = null;
+
+ if (desiredFile.exists()) {
+ result = new FileImpl(desiredFile, rootDirFile);
+ }
+ return result;
+ }
+
+ public boolean isRoot()
+ {
+ boolean result = (rootDirFile == file);
+ return result;
+ }
+
+ public List<IFile> listFiles()
+ {
+ List<IFile> files = new ArrayList<IFile>();
+ File[] filesInDir = file.listFiles();
+ if (filesInDir != null) {
+ for (File f : filesInDir) {
+ if (f.isFile()) {
+ files.add(new FileImpl(f, rootDirFile));
+ } else if (f.isDirectory()) {
+ files.add(new DirectoryImpl(f, rootDirFile));
+ }
+ }
+ }
+ return files;
+ }
+
+ public Iterator<IFile> iterator()
+ {
+ Iterator<IFile> result = listFiles().iterator();
+ return result;
+ }
+
+ @Override
+ public IDirectory getParent()
+ {
+ IDirectory result = isRoot() ? null : super.getParent();
+ return result;
+ }
+
+ @Override
+ public IDirectory convert()
+ {
+ return this;
+ }
+
+ @Override
+ public InputStream open() throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long getLastModified()
+ {
+ long result = super.getLastModified();
+ for (IFile aFile : this) {
+ long tmpLastModified = aFile.getLastModified();
+
+ if (tmpLastModified > result) result = tmpLastModified;
+ }
+ return result;
+ }
+}
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java?rev=899518&r1=899517&r2=899518&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java (original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java Fri Jan 15 02:17:38 2010
@@ -1,143 +1,143 @@
-/*
- * 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 WARRANTIESOR 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.aries.application.utils.filesystem.impl;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.aries.application.filesystem.IDirectory;
-import org.apache.aries.application.filesystem.IFile;
-
-/**
- * An implementation of IFile that represents a java.io.File.
- */
-public class FileImpl implements IFile
-{
-
- /** The name of the root directory of the file system */
- protected String rootDir;
- /** This file in the file system */
- protected File file;
- /** The root File in the file system */
- protected File rootDirFile;
- /** The name of this file in the vFS */
- private String name;
-
- /**
- * @param f this file.
- * @param rootFile the root of the vFS.
- */
- public FileImpl(File f, File rootFile)
- {
- file = f;
- this.rootDirFile = rootFile;
- rootDir = rootFile.getAbsolutePath();
-
- if (f == rootFile) name = "";
- else name = file.getAbsolutePath().substring(rootDir.length() + 1);
- }
-
- public IDirectory convert()
- {
- return null;
- }
-
- public long getLastModified()
- {
- long result = file.lastModified();
- return result;
- }
-
- public String getName()
- {
- return name;
- }
-
- public IDirectory getParent()
- {
- IDirectory parent = new DirectoryImpl(file.getParentFile(), rootDirFile);
- return parent;
- }
-
- public long getSize()
- {
- long size = file.length();
- return size;
- }
-
- public boolean isDirectory()
- {
- boolean result = file.isDirectory();
- return result;
- }
-
- public boolean isFile()
- {
- boolean result = file.isFile();
- return result;
- }
-
- public InputStream open() throws IOException
- {
- InputStream is = new FileInputStream(file);
- return is;
- }
-
- public IDirectory getRoot()
- {
- IDirectory root = new DirectoryImpl(rootDirFile, rootDirFile);
- return root;
- }
-
- public URL toURL() throws MalformedURLException
- {
- URL result = file.toURL();
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null) return false;
- if (obj == this) return true;
-
- if (obj.getClass() == getClass()) {
- return file.equals(((FileImpl)obj).file);
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return file.hashCode();
- }
-
- @Override
- public String toString()
- {
- return file.getAbsolutePath();
- }
+/*
+ * 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 WARRANTIESOR 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.aries.application.utils.filesystem.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.filesystem.IFile;
+
+/**
+ * An implementation of IFile that represents a java.io.File.
+ */
+public class FileImpl implements IFile
+{
+
+ /** The name of the root directory of the file system */
+ protected String rootDir;
+ /** This file in the file system */
+ protected File file;
+ /** The root File in the file system */
+ protected File rootDirFile;
+ /** The name of this file in the vFS */
+ private String name;
+
+ /**
+ * @param f this file.
+ * @param rootFile the root of the vFS.
+ */
+ public FileImpl(File f, File rootFile)
+ {
+ file = f;
+ this.rootDirFile = rootFile;
+ rootDir = rootFile.getAbsolutePath();
+
+ if (f == rootFile) name = "";
+ else name = file.getAbsolutePath().substring(rootDir.length() + 1);
+ }
+
+ public IDirectory convert()
+ {
+ return null;
+ }
+
+ public long getLastModified()
+ {
+ long result = file.lastModified();
+ return result;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public IDirectory getParent()
+ {
+ IDirectory parent = new DirectoryImpl(file.getParentFile(), rootDirFile);
+ return parent;
+ }
+
+ public long getSize()
+ {
+ long size = file.length();
+ return size;
+ }
+
+ public boolean isDirectory()
+ {
+ boolean result = file.isDirectory();
+ return result;
+ }
+
+ public boolean isFile()
+ {
+ boolean result = file.isFile();
+ return result;
+ }
+
+ public InputStream open() throws IOException
+ {
+ InputStream is = new FileInputStream(file);
+ return is;
+ }
+
+ public IDirectory getRoot()
+ {
+ IDirectory root = new DirectoryImpl(rootDirFile, rootDirFile);
+ return root;
+ }
+
+ public URL toURL() throws MalformedURLException
+ {
+ URL result = file.toURL();
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null) return false;
+ if (obj == this) return true;
+
+ if (obj.getClass() == getClass()) {
+ return file.equals(((FileImpl)obj).file);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return file.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return file.getAbsolutePath();
+ }
}
\ No newline at end of file
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/FileImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain