| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| WebPhotos |
|
| 2.5;2,5 | ||||
| WebPhotos$1 |
|
| 2.5;2,5 |
| 1 | /** | |
| 2 | * Copyright 2008 WebPhotos | |
| 3 | * | |
| 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 | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 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. | |
| 15 | */ | |
| 16 | package net.sf.webphotos; | |
| 17 | ||
| 18 | import java.io.File; | |
| 19 | import java.io.PrintWriter; | |
| 20 | import java.net.InetAddress; | |
| 21 | import net.sf.webphotos.gui.FrameWebFotos; | |
| 22 | import net.sf.webphotos.util.Util; | |
| 23 | import org.apache.derby.drda.NetworkServerControl; | |
| 24 | import org.apache.log4j.Logger; | |
| 25 | ||
| 26 | /** | |
| 27 | * Classe responsável pelo inicio do sistema WebPhotos. Realiza algumas rotinas | |
| 28 | * para início do sistema. Os dados são trabalhados somente no método principal. | |
| 29 | */ | |
| 30 | 0 | public class WebPhotos { |
| 31 | ||
| 32 | 3 | private static Logger log = Logger.getLogger(WebPhotos.class); |
| 33 | ||
| 34 | /** | |
| 35 | * Contêm uma série de rotinas para inicialização do programa. No primeiro | |
| 36 | * momento, o cache do FTP é apagado. Logo após é feita uma busca do arquivo | |
| 37 | * de configuração. é obtido o driver do DB, e são preparadas as conexões | |
| 38 | * para usar Socks Proxy. Por último é exibida a tela de login ao usuário. | |
| 39 | * | |
| 40 | * @param args Argumentos do método main. | |
| 41 | */ | |
| 42 | public static void main(String args[]) { | |
| 43 | ||
| 44 | try { | |
| 45 | ||
| 46 | // apaga o cache ftp | |
| 47 | 3 | File cacheftp = new File("CacheFTP.txt"); |
| 48 | 3 | if (cacheftp.isFile()) { |
| 49 | 0 | cacheftp.delete(); |
| 50 | } | |
| 51 | ||
| 52 | 3 | Util.loadSocksProxy(); |
| 53 | 3 | final String derbyDrdaHost = Util.getConfig().getString("derby.drda.host"); |
| 54 | 3 | final int derbyDrdaPortNumber = Util.getConfig().getInt("derby.drda.portNumber"); |
| 55 | 3 | final boolean derbyDrdaStartNetworkServer = Util.getConfig().getBoolean("derby.drda.startNetworkServer"); |
| 56 | ||
| 57 | /** | |
| 58 | * FIXEME: change this code to derby.drda.startNetworkServer=true | |
| 59 | */ | |
| 60 | 3 | if (derbyDrdaStartNetworkServer) { |
| 61 | 3 | NetworkServerControl server = new NetworkServerControl(InetAddress.getByName(derbyDrdaHost), derbyDrdaPortNumber); |
| 62 | 3 | server.start(new PrintWriter(Util.out)); |
| 63 | 3 | server.setMaxThreads(100); |
| 64 | } | |
| 65 | ||
| 66 | 3 | BancoImagem.loadUIManager(); |
| 67 | 3 | BancoImagem.loadDBDriver(); |
| 68 | ||
| 69 | // mostra tela de login | |
| 70 | 3 | BancoImagem.login(); |
| 71 | ||
| 72 | // Eficiente para produção - Ruim para depuração | |
| 73 | 3 | java.awt.EventQueue.invokeLater(new Runnable() { |
| 74 | @Override | |
| 75 | public void run() { | |
| 76 | 3 | FrameWebFotos.getInstance().setVisible(true); |
| 77 | 3 | } |
| 78 | }); | |
| 79 | ||
| 80 | 0 | } catch (Exception e) { |
| 81 | 0 | log.error("Não foi possível iniciar o WebPhotos", e); |
| 82 | 3 | } |
| 83 | ||
| 84 | 3 | } |
| 85 | } |