2 * Copyright (C) 2007-2012 Argeo GmbH
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.
16 package org
.argeo
.slc
.aether
.spring
;
18 import org
.sonatype
.aether
.repository
.Authentication
;
19 import org
.sonatype
.aether
.repository
.RemoteRepository
;
20 import org
.springframework
.beans
.factory
.BeanNameAware
;
21 import org
.springframework
.beans
.factory
.FactoryBean
;
23 /** Simplifies the definition of a remote factory using Spring */
24 public class RemoteRepositoryFactory
implements BeanNameAware
, FactoryBean
{
25 private String beanName
;
28 private String type
= "default";
29 private String username
;
30 private String password
;
32 public Object
getObject() throws Exception
{
33 RemoteRepository remoteRepository
= new RemoteRepository(
34 id
!= null ? id
: beanName
, type
, url
);
35 if (username
!= null) {
36 Authentication authentication
= new Authentication(username
,
38 remoteRepository
.setAuthentication(authentication
);
40 return remoteRepository
;
43 public Class
<?
> getObjectType() {
44 return RemoteRepository
.class;
47 public boolean isSingleton() {
51 public void setBeanName(String name
) {
56 public void setId(String id
) {
60 public void setUrl(String url
) {
64 public void setType(String type
) {
68 public void setUsername(String username
) {
69 this.username
= username
;
72 public void setPassword(String password
) {
73 this.password
= password
;