added client and server REST support

This commit is contained in:
2015-03-29 22:16:27 +02:00
parent 9b37788528
commit 4a9a01068f
15 changed files with 692 additions and 281 deletions

View File

@@ -1,17 +1,15 @@
import com.thoughtworks.xstream.XStream;
import model.PkgData;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.junit.Test;
import pacbase.Parser;
import service.PacmanService;
import javax.naming.*;
import java.io.File;
import java.io.FileInputStream;
import java.nio.charset.Charset;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
@@ -19,14 +17,14 @@ import java.util.*;
*/
public class ParseTest
{
@Test
// @Test
public void test() throws Exception
{
Collection<File> ls = FileUtils.listFiles(new File("/var/cache/pacman/pkg"), new RegexFileFilter(".*\\.pkg\\.tar\\.xz"), DirectoryFileFilter.DIRECTORY);
int i=0;
int i = 0;
List<PkgData> lista = new ArrayList<>();
for(File file : ls)
for (File file : ls)
{
PkgData data = Parser.parseFile(file);
lista.add(data);
@@ -35,4 +33,41 @@ public class ParseTest
}
System.out.print(lista);
}
@Test
public void invokeStatelessBean() throws NamingException, IOException
{
// Let's lookup the remote stateless calculator
Properties prop = new Properties();
InputStream in = getClass().getClassLoader().getResourceAsStream("jboss-ejb-client.properties");
prop.load(in);
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://odroid-u3:8080");
// prop.put(Context.PROVIDER_URL, "remote://odroid-u3:4447");
prop.put(Context.SECURITY_PRINCIPAL, "jpacrepo");
prop.put(Context.SECURITY_CREDENTIALS, "password01.");
prop.put("jboss.naming.client.ejb.context", true);
Context context = new InitialContext(prop);
Context ctx = new InitialContext(prop);
traverseJndiNode("/", context);
// final PacmanService stateService = (PacmanService) ctx.lookup("/jpacrepo-1.0/remote/PacmanServiceEJB!service.PacmanService");
final PacmanService stateService = (PacmanService) ctx.lookup("/jpacrepo-1.0/PacmanServiceEJB!service.PacmanService");
stateService.syncDB();
}
private static void traverseJndiNode(String nodeName, Context context) {
try {
NamingEnumeration<NameClassPair> list = context.list(nodeName);
while (list.hasMore()){
String childName = nodeName + "" + list.next().getName();
System.out.println(childName);
traverseJndiNode(childName, context);
}
} catch (NamingException ex) {
// We reached a leaf
}
}
}