Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospacebackend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Bertocco
vospacebackend
Commits
8d84bca4
Commit
8d84bca4
authored
8 years ago
by
Sara Bertocco
Browse files
Options
Downloads
Patches
Plain Diff
New working version after Victoria trip - fix a typo
parent
3030b0c9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/oats/vospacebackend/implementation/VOSpaceBackendImplFactory.java
+103
-0
103 additions, 0 deletions
...pacebackend/implementation/VOSpaceBackendImplFactory.java
with
103 additions
and
0 deletions
src/main/java/it/inaf/oats/vospacebackend/implementation/VOSpaceBackendImplFactory.java
0 → 100644
+
103
−
0
View file @
8d84bca4
/**_____________________________________________________________________________
*
* OATS - INAF
* Osservatorio Astronomico di Tireste - Istituto Nazionale di Astrofisica
* Astronomical Observatory of Trieste - National Institute for Astrophysics
* ____________________________________________________________________________
*
* Copyright (C) 20016 Istituto Nazionale di Astrofisica
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* _____________________________________________________________________________
**/
package
it.inaf.oats.vospacebackend.implementation
;
import
org.apache.log4j.Logger
;
import
it.inaf.oats.vospacebackend.exceptions.ExceptionMessage
;
import
it.inaf.oats.vospacebackend.exceptions.VOSpaceBackendException
;
import
it.inaf.oats.vospacebackend.utils.ConfigReader
;
import
java.text.MessageFormat
;
public
class
VOSpaceBackendImplFactory
{
private
static
final
String
CONFIG_FILE_NAME
=
"VOSpace.properties"
;
private
static
final
Logger
log
=
Logger
.
getLogger
(
VOSpaceBackendImplFactory
.
class
);
private
static
String
VOSpaceBackImplName
=
new
String
();
public
VOSpaceBackendImplFactory
()
throws
VOSpaceBackendException
{
ConfigReader
myConf
=
null
;
try
{
myConf
=
new
ConfigReader
(
CONFIG_FILE_NAME
);
}
catch
(
Exception
e
)
{
ExceptionMessage
exMsg
=
new
ExceptionMessage
();
log
.
debug
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"UNABLE_TO_READ_PROPERTIES"
),
CONFIG_FILE_NAME
));
throw
new
VOSpaceBackendException
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"UNABLE_TO_READ_PROPERTIES"
),
CONFIG_FILE_NAME
));
}
try
{
this
.
VOSpaceBackImplName
=
myConf
.
getProperty
(
"it.inaf.oats.vospacebackend.implementation.VOSpaceBackendImpl"
);
}
catch
(
Exception
e
)
{
ExceptionMessage
exMsg
=
new
ExceptionMessage
();
log
.
debug
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"PROPERTY_NOT_FOUND"
),
"it.inaf.oats.vospacebackend.implementation.VOSpaceBackendImpl"
,
CONFIG_FILE_NAME
));
throw
new
VOSpaceBackendException
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"PROPERTY_NOT_FOUND"
),
"it.inaf.oats.vospacebackend.implementation.VOSpaceBackendImpl"
,
CONFIG_FILE_NAME
));
}
}
public
VOSpaceBackend
getVOSpaceBackImpl
()
throws
VOSpaceBackendException
{
log
.
debug
(
"Try to get object: "
+
this
.
VOSpaceBackImplName
);
return
(
VOSpaceBackend
)
this
.
buildObject
(
this
.
VOSpaceBackImplName
);
}
private
Object
buildObject
(
String
myBackendImpl
)
throws
VOSpaceBackendException
{
Object
result
=
null
;
try
{
//note that, with this style, the implementation needs to have a
//no-argument constructor!
Class
implClass
=
Class
.
forName
(
myBackendImpl
);
result
=
implClass
.
newInstance
();
}
catch
(
ClassNotFoundException
ex
)
{
log
.
debug
(
"CLASS_NOT_FOUND"
);
ExceptionMessage
exMsg
=
new
ExceptionMessage
();
throw
new
VOSpaceBackendException
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"CLASS_NOT_FOUND"
),
myBackendImpl
));
}
catch
(
InstantiationException
ex
)
{
log
.
debug
(
"UNABLE_TO_INSTANTIATE"
);
ExceptionMessage
exMsg
=
new
ExceptionMessage
();
throw
new
VOSpaceBackendException
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"UNABLE_TO_INSTANTIATE"
),
myBackendImpl
));
}
catch
(
IllegalAccessException
ex
)
{
log
.
debug
(
"UNABLE_TO_ACCESS"
);
ExceptionMessage
exMsg
=
new
ExceptionMessage
();
throw
new
VOSpaceBackendException
(
MessageFormat
.
format
(
exMsg
.
getMessage
(
"UNABLE_TO_ACCESS"
),
myBackendImpl
));
}
return
result
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment