2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.core
.execution
;
21 import org
.springframework
.beans
.factory
.FactoryBean
;
22 import org
.springframework
.core
.io
.Resource
;
23 import org
.springframework
.util
.Assert
;
25 /** Retrieve an OS File from the given resource. */
26 public class OsFileFactoryBean
implements FactoryBean
{
27 private ExecutionResources executionResources
;
28 private Resource resource
;
29 private Boolean overwrite
= false;
31 /** Return an existing file on the file system. */
32 public Object
getObject() throws Exception
{
33 Assert
.notNull(executionResources
, "executionResources is null");
34 Assert
.notNull(resource
, "resource is null");
35 return executionResources
.getAsOsPath(resource
, overwrite
);
38 /** Return {@link Object} because CGLIB is unable to proxy {@link File}.*/
39 public Class
<?
extends Object
> getObjectType() {
40 return CharSequence
.class;
43 public boolean isSingleton() {
47 /** The execution resources object. */
48 public void setExecutionResources(ExecutionResources executionResources
) {
49 this.executionResources
= executionResources
;
52 /** The resource to access. */
53 public void setResource(Resource resource
) {
54 this.resource
= resource
;
58 * Whether to overwrite the resource if it already exists. Default is
61 public void setOverwrite(Boolean overwrite
) {
62 this.overwrite
= overwrite
;